Jumping?

Started by
23 comments, last by grhodes_at_work 19 years, 8 months ago
When considering physics, jumping consists in an initial change of velocity of the character, which then leaves the ground. While in the air, he is only subject to gravity, which alters his velocity (and thus his movement) until a collision occurs.

If the initial change in velocity gives you an initial velocity of V0 (it's a vector), the position of the jumper is OM(t) and if the gravitational force is F, then at any time t after the jump, the position of the object would be:
OMx/z(t) = OMx/z(0) + tV0x/z
OMy(t) = OMy(0) + tV0y + t2F

Usually, F is -Mg, where g is 9.81 m.s-2 on Earth and M is the mass of the object, in kg.

However, this is a very bad approach to jumps in video games, since this prevents you from controlling the player during the jump. You have three aproaches there:

- Physics approach: keep the above formulae. Whenever a player jumps, he loses control.
- FPS approach: the y component of the movement remains the same, however the player still controls the x/z component as if he was on the ground (some games reduce the amount of control slightly while the player is in the air).
- Platform game approach: the player has full control over the x/z component. Also, the gravity is not constant: the player might keep the jump key pressed for a while. When it is first pressed (and the player is on the ground) F is set to 0. If the key is kept pressed, it increases slowly towards its normal value (the player jumps higher). If it is released, F automatically retrieves its normal value.


Advertisement
to be honest i can't tell if he's talking about the mathematical physics thing or the c language version of try/catch. If you want a player to jump, your physics engine should already handle gravity for objects, so all you have to do is increase the upward component of the object's velocity (then your integrator handles positions etc)
Why don't alcoholics make good calculus teachers?Because they don't know their limits!Oh come on, Newton wasn't THAT smart...
o.O rephrase.
My fellow Americans I have just signed legislation that outlaws Russia forever. Bombing will commence in five minutes.
Maybe you mean the setjmp and longjmp functions?

http://www.linuxgazette.com/issue90/raghu.html

edit: fixed typos. Shame, fingers... shame!
Bad OP, keeping us guessing. I rated you down but for some reason it only increased your rating, so that kinda sux.
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius
[offtopic]
jumping?...goto?....trolling?...
[/offtopic]
really,just interesting what it was...
no idea what just wasted my 30 seconds, but i do know im going to give the OP the lowest rating and hope this 'thread' gets deleted.
I'm so sorry Iwas sleepy and then left for the weekend.

I was wondering were to get some tours for adding jumping in your game engine? help any?
Eat food and life is yours!
ToohrVyk already answered above:

Quote:Original post by ToohrVyk
When considering physics, jumping consists in an initial change of velocity of the character, which then leaves the ground. While in the air, he is only subject to gravity, which alters his velocity (and thus his movement) until a collision occurs.

If the initial change in velocity gives you an initial velocity of V0 (it's a vector), the position of the jumper is OM(t) and if the gravitational force is F, then at any time t after the jump, the position of the object would be:
OMx/z(t) = OMx/z(0) + tV0x/z
OMy(t) = OMy(0) + tV0y + t2F

Usually, F is -Mg, where g is 9.81 m.s-2 on Earth and M is the mass of the object, in kg.

However, this is a very bad approach to jumps in video games, since this prevents you from controlling the player during the jump. You have three aproaches there:

- Physics approach: keep the above formulae. Whenever a player jumps, he loses control.
- FPS approach: the y component of the movement remains the same, however the player still controls the x/z component as if he was on the ground (some games reduce the amount of control slightly while the player is in the air).
- Platform game approach: the player has full control over the x/z component. Also, the gravity is not constant: the player might keep the jump key pressed for a while. When it is first pressed (and the player is on the ground) F is set to 0. If the key is kept pressed, it increases slowly towards its normal value (the player jumps higher). If it is released, F automatically retrieves its normal value.
Ok thank you now how long will I be at 982?
that bites!
Eat food and life is yours!

This topic is closed to new replies.

Advertisement