Here is a script for realistic jumping using gravity:
when gf clicked set [Gravity v] to [0] repeat [however long you want it to repeat] if <touching color [color of ground]> set [Gravity v] to [0] change y by [1] set [Gravity v] to [the larger this number is, the higher your sprite will jump] else change [Gravity v] by [-1] change y by (Gravity) end end
Offline
fg123 wrote:
Nice script! Although I recommend Velocity for gravity. It's much more smooth.
This is the same as y velocity. I just used the variable "gravity" in case people became confused.
Offline
skippito wrote:
fg123 wrote:
Nice script! Although I recommend Velocity for gravity. It's much more smooth.
This is the same as y velocity. I just used the variable "gravity" in case people became confused.
I see, but usually, instead of changing gravity by -1, we use:
This gives a smooth decline too.
set [gravity v] to ((gravity) * (0.95))
Last edited by fg123 (2012-06-30 13:21:55)
Offline
skippito wrote:
Here is a script for realistic jumping using gravity:
when gf clicked set [Gravity v] to [0] repeat [however long you want it to repeat] if <touching color [color of ground]> set [Gravity v] to [0] change y by [1] set [Gravity v] to [the larger this number is, the higher your sprite will jump] else change [Gravity v] by [-1] change y by (Gravity) end end
I used this and the sprite kept ending up staying in the air after it jumped... did i do something wrong? I copied exactly..
Last edited by DragonLoverGirl (2012-06-30 23:45:13)
Offline
DragonLoverGirl wrote:
skippito wrote:
Here is a script for realistic jumping using gravity:
when gf clicked set [Gravity v] to [0] repeat [however long you want it to repeat] if <touching color [color of ground]?> set [Gravity v] to [0] change y by [1] set [Gravity v] to [the larger this number is, the higher your sprite will jump] else change [Gravity v] by [-1] change y by (Gravity) end endI used this and the sprite kept ending up staying in the air after it jumped... did i do something wrong? I copied exactly..
You want to make sure that the
repeat end [however long you want it to repeat]is changed to a
forever end.
Last edited by fg123 (2012-07-01 02:36:13)
Offline
hey i have a velocity script in my game that if you press dont press the button that makes you jump, it will bring you down gradually faster instead of staying the same speed while falling. i can post the script itself if you want me to?
Offline
oops sorry but why does it bounce like that?
Offline