Fangames > Programming Questions
Gravity
(1/1)
AlexGuy:
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?
Aelya:
what's your code
AlexGuy:
--- Quote from: Aelya on March 23, 2015, 06:09:58 PM ---what's your code
--- End quote ---
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 :/
klazen108:
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):
To fix it, you need to change that line in the step event to
--- Code: ---gravity=player_gravity
--- End code ---
and add the following to the create event:
--- Code: ---player_gravity=0.4
--- End code ---
Then you can edit your code to be
--- Code: ---with(player){player_gravity = 0.2;}
--- End code ---
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!)
Navigation
[0] Message Index
Go to full version