## [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.
Caligari87
Posts: 6181
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

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

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.

Caligari87
Posts: 6181
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

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

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.

Nash

Posts: 17450
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

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

Neat, thanks for sharing!
Tormentor667
Posts: 13534
Joined: Wed Jul 16, 2003 3:52 am

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

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

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

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.

Caligari87
Posts: 6181
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

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

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.

You do not have the required permissions to view the files attached to this post.
Beed28
Posts: 598
Joined: Sun Feb 24, 2013 4:07 pm
Location: United Kingdom

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

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

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

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

Thank you a lot for sharing this, Caligari_87!
Nash

Posts: 17450
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

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

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
Tormentor667
Posts: 13534
Joined: Wed Jul 16, 2003 3:52 am

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

This is really impressive
Caligari87
Posts: 6181
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

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

@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.

Nash

Posts: 17450
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

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

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.