I Wanna Community
Fangames => Game Design => Programming Questions => Topic started by: AlexGuy on March 23, 2015, 03:13:29 PM
-
How can I make an object, that if the player goes through the object, his gravity changes to lower gravity for example? I tried to program an object, but it didn't work. Could someone help me please?
-
what's your code
-
what's your code
well, I chosed the object which should change kid's gravity and made collision player and then this creation code: "with(player){gravity = 0.2;}"
simply as that :/
-
That's because the player sets his gravity back to normal every step (here's a picture from Seph's Engine, but it works the same in all engines):
(https://i.imgur.com/HHUDb4o.png)
To fix it, you need to change that line in the step event to
gravity=player_gravity
and add the following to the create event:
player_gravity=0.4
Then you can edit your code to be
with(player){player_gravity = 0.2;}
And it should work! (Remember to reset player_gravity=0.4 when you're done with it, on game load or room start or game reset etc, or else people can keep their different gravities in places you wouldn't expect!)