Reverse Gravity

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Misery
Posts: 157
Joined: Sun Nov 04, 2018 4:57 pm

Reverse Gravity

Post by Misery »

Is it possible to reverse gravity and make a player fall up and hit the ceiling, i.e. via a trap or linedef action, etc?
User avatar
Player701
 
 
Posts: 1401
Joined: Wed May 13, 2009 3:15 am
Discord: Player701#8214
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: Reverse Gravity

Post by Player701 »

You can use [wiki]Sector_SetGravity[/wiki] to change the gravity and [wiki]ThrustThingZ[/wiki] to give the player some vertical speed so that the new gravity takes effect. Assuming the tag of the sector where you want to change the gravity is 1, the following script can be used:

Code: Select all

script 1 (void)
{
    Sector_SetGravity(1, -1, 0);
    ThrustThingZ(0, 1, 0, 1);
}
This script is supposed to be activated when the player enter the sector; you can use walk-over line triggers or a sector action thing for that. Note that negative (or, rather, non-positive) gravitiy is poorly supported by the engine and may not always work the way you expect it to.
User avatar
Misery
Posts: 157
Joined: Sun Nov 04, 2018 4:57 pm

Re: Reverse Gravity

Post by Misery »

I am hoping it will work by slowly falling up. The slow start will create more tension than if the player simply shoots upward. But if it can work by falling slowly at first, and then building velocity like in a real fall, it would be perfect for what I want to do.
User avatar
Player701
 
 
Posts: 1401
Joined: Wed May 13, 2009 3:15 am
Discord: Player701#8214
Graphics Processor: nVidia with Vulkan support
Location: Russia

Re: Reverse Gravity

Post by Player701 »

Misery wrote:I am hoping it will work by slowly falling up.
Yes, it will work exactly like that since it effectively reverts the sign of the gravitational acceleration.
User avatar
Misery
Posts: 157
Joined: Sun Nov 04, 2018 4:57 pm

Re: Reverse Gravity

Post by Misery »

Yes, it works perfectly now. Thanks 👍

Return to “Scripting”