Here is a script for realistic jumping using gravity:
whenclicked
setGravity ▼to0repeathowever long you want it to repeatiftouching colorcolor of groundsetGravity ▼to0change y by1setGravity ▼tothe larger this number is, the higher your sprite will jumpelsechangeGravity ▼by-1change y byGravity
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.
setgravity ▼togravity*0.95
Last edited by fg123 (2012-06-30 13:21:55)
Offline
skippito wrote:
Here is a script for realistic jumping using gravity:
whenclicked
setGravity ▼to0repeathowever long you want it to repeatiftouching colorcolor of groundsetGravity ▼to0change y by1setGravity ▼tothe larger this number is, the higher your sprite will jumpelsechangeGravity ▼by-1change y byGravity
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:
whenclicked
setGravity ▼to0repeathowever long you want it to repeatiftouching colorcolor of ground?setGravity ▼to0change y by1setGravity ▼tothe larger this number is, the higher your sprite will jumpelsechangeGravity ▼by-1change y byGravityI 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
is changed to arepeat
.forever
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