[Camera Demo] Playground swing

Handy guides on how to do things, written by users for users.

Moderators: GZDoom Developers, Raze Developers

Forum rules
Please don't start threads here asking for help. This forum is not for requesting guides, only for posting them. If you need help, the Editing forum is for you.
Post Reply
User avatar
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

[Camera Demo] Playground swing

Post by gwHero »

So I started a megawad a few years ago. Had a lot of fun in creating it, but I never finished it and nothing was published since I made a lot of beginner's mistakes and did not feel to start all over again with the same theme.

However, some parts might be worth sharing. The first level contained a city map that had a children's playground with a swing, so I have put this into a demo wad to illustrate what you can do with camera's in GZDoom. Experienced modders might know all the way, but for newbies it might be useful. Also, if someone wants to have a swing for a city map that's a little bit more than just decoration, here's a start...

It's not a 'real swing' in a way that sectors are moving (maybe it could be done with polyobjects but I'm not sure if that would be very convincing since these cannot have floors), but it's done with camera's to give the illusion of a swing.

I have included the demo wad so you can try the swing yourself. After starting the wad in GZDoom, just step on one of the swings (no too fast), and it will automatically start. As long as you stand still, you'll keep swinging :) Just press forward or backward again to step off.

(note: if you do not step on the swing in the middle of the seat, but more to the edges, it can happen that the swing cord is blocking you, preventing you from stepping off the swing with the forward key - just use the backward key in that case)

Technical details.
At each side of each swing, linedefs are placed to start or stop the swing by executing a script when a player crosses them (one line is for stepping on, the other one for stepping off; events are triggered only from the front sides to distinguish the actions). The first parameter tells the script if the swing must be started or stopped, the other parameters are the camera tid's. Each swing has 2 camera's, one for each direction.

Screenprint:
[imgur] https://imgur.com/a/YNCbj[/imgur]

Map detail:
[imgur] https://imgur.com/a/93j1Q[/imgur]

Script:

Code: Select all

script 30(int swing, int camera, int camera2)
{
	if (swing==1)	// step on
	{
		SetActorProperty(0, APROP_RenderStyle, STYLE_None); // hide the player 
		Thing_Activate(camera);
		ChangeCamera(camera, 0, 0);
		Thing_DeActivate(camera2);	// disable other camera
	}
	else	// step off
	{
		SetActorProperty(0, APROP_RenderStyle, STYLE_Normal); // bring player back
		Thing_DeActivate(camera);
		ChangeCamera(0, 0, 0);	// switch back to player view
		Thing_DeActivate(camera2); // disable both camera's since player can step off from the other side
	}
}
For more details, just open the map in GZDB bugfix.


Remark 1. The swing itself works in OpenGL as well as the software renderer. However, because I used 3d platform slopes for the construction of the swing in the demo, these parts will not be visible in the software renderer. To use the swing in a map that should support the software renderer, change the construction poles.

Remark 2. To reduce the number of tags and 3d floors, the construction of the swing uses multiple tags per sector. You have to use GZDB bugfix to edit/view these correctly.

Used techniques: camera's, 3d floors, 3d slopes, ACS scripting
Attachments
MAP01.wad
Demo wad swing
(42.42 KiB) Downloaded 147 times
User avatar
Zen3001
Posts: 412
Joined: Fri Nov 25, 2016 7:17 am
Location: some northern german shithole

Re: [Camera Demo] Playground swing

Post by Zen3001 »

you could creat 3d models with a swinging animation
Post Reply

Return to “Tutorials”