[GZDoom] Combining pitch and roll to "tilt" the level

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

[GZDoom] Combining pitch and roll to "tilt" the level

Post by Caligari87 »

Working on a very small project, and for one of the effects I'd like to put the entire level on an apparent "tilt". So far I have accomplished the basic idea (sort of), but I need some math/input help.

Code: Select all

#library "global"
#include "zcommon.acs"
script "leveltilt" ENTER {
	while (1) {
		ChangeActorRoll(0,sin(getactorangle(0))/50,1);
		setactorpitch(0,cos(getactorangle(0))/50);
		delay(1);
	}
}
Currently if you LOADACS this script, it puts the whole level on a very convincing tilt, about 30 degrees to the east. This is exactly what I want. However, as you can probably guess, this locks the player's pitch. Taking out that part keeps the roll based on the player's angle, but it's not quite as pretty. Has anyone figured out the math or code that would allow for a true "yaw", at least within reasonable bounds? I'm not gonna be flipping 180 or anything.

8-)
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Caligari87 »

HAH! I think I managed to figure it out on my own!

Code: Select all

int True_Pitch;

script "gettrueorientation" ENTER {
	True_Angle=GetActorAngle(0);
	True_Pitch=GetActorPitch(0);
	while(1) {
		True_Pitch-=GetPlayerInput(0,INPUT_PITCH);
		delay(1);
	}
}

script "leveltilt" ENTER {
	while (1) {
		ChangeActorRoll(0,sin(getactorangle(0))/50,1);
		setactorpitch(0,True_Pitch+cos(getactorangle(0))/50);
		delay(1);
	}
}
Basically tracking the player's "true pitch" with GetPlayerInput allows exactly what I wanted! So I guess this is solved, but I'll leave it for anyone else who might find it interesting.

8-)
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Nash »

Neat, thanks for sharing!
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Tormentor667 »

Can you share a demo map as well?
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Caligari87 »

It's actually not map-dependent. Just compile that script into a PK3, add a LOADACS lump, and voila! MAP01 on a slight eastward tilt!

I'm sure it can be made more robust with an angle offset and/or intensity modifier, and you could make entire levels that rock back and forth like a boat on an ocean, or in circles like a tilt-a-whirl. I also added a little SetActorVelocity when the player isn't moving, so they slowly "slide down" the slope. It's pretty damned convincing.

In fact, I'll share the rest of the code when I get home later tonight. I'd be interested to see what someone else might come up with.

8-)
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Caligari87 »

Okay, here's leveltilt.pk3. Simply load in GZDoom with any mapset (should be fully compatible unless there's a script name conflict) and enjoy. Careful, it can be a little disorienting.

8-)
Attachments
leveltilt.pk3
Tilts any level, play with the script to set angles and amounts.
(916 Bytes) Downloaded 170 times
User avatar
Beed28
Posts: 598
Joined: Sun Feb 24, 2013 4:07 pm
Location: United Kingdom

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Beed28 »

This looks neat. Reminds me of my Megabounce project, which I'll probably revive at some point.

I'll definitely play around with this.
User avatar
Ravick
Posts: 2003
Joined: Sun Aug 22, 2010 10:59 pm
Location: Tubarão, Brasil
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Ravick »

I've made a small test:


Thank you a lot for sharing this, Caligari_87!
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Nash »

Hmmm, the pitch movement is very jittery for me. I took a quick look at the code inside the PK3, maybe if you combine everything into a single while loop (therefore only 1 script instead of 2) it would be fix the problem? I didn't test it though, it was just a quick observation
User avatar
Tormentor667
Posts: 13533
Joined: Wed Jul 16, 2003 3:52 am
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Tormentor667 »

This is really impressive :)
User avatar
Caligari87
Admin
Posts: 6174
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Caligari87 »

@Nash: I didn't notice any jitter on my side, but maybe I'm just used to it or something. It probably would be better to combine it into one script, shouldn't be hard at all.

I've also used SetActorPitch instead of ChangeActorPitch... maybe I should swap those out for the interpolation option, that might help.

8-)
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [GZDoom] Combining pitch and roll to "tilt" the level

Post by Nash »

Ravick wrote:I've made a small test:


Thank you a lot for sharing this, Caligari_87!
Late response but that "jitteriness" I was talking about is very evident in this video - see how the view angle moves in hard, quantized "steps" instead of being really smooth.
Locked

Return to “Editing (Archive)”