Game Development Community

Realistic Jumping

by John Klotz · in Torque Game Builder · 08/01/2006 (7:46 am) · 1 replies

How would you go about creating a jumping effect that looks semi-real? I set my characters linear velocity Y and create a constant force but the problem I have is that I can jump in mid-air when I do this. Is a collision function with the platform necessary for this? How would I go about doing this?

Thank you

#1
08/01/2006 (7:53 am)
You could check whether the user is currently on the ground or in mid-air. If the user is colliding with the floor, you could set your $ableToJump status to true. Then, if the jumpkey is pressed and $ableToJump is true, you could setImpulse to shoot your player up and set $ableToJump to false. Assuming you have a constant force downwards, representing gravity, the player should then fall back down. When it collides with the ground, $ableToJump will reset back to true and it should be possible to do it again.
This is all off the top of my head and isn't tested, so it may not work fully, but it seems to me to be reasonable.