**0**

# Jump math

Started by doyleman77, Aug 27 2011 09:43 PM

4 replies to this topic

###
#1
Members - Reputation: **367**

Posted 27 August 2011 - 09:43 PM

I was trying to figure what equation would be best related to jumping, and for whatever reason i'm convinced it is related to the parabola quadratic equation; which I also don't see how it could work (maybe i'm looking at it the wrong way?)

Anyway, would anyone be as kind as to tipping me off in the right direction for figuring what the players height of jump should be based off of x-Time if button is held?

Anyway, would anyone be as kind as to tipping me off in the right direction for figuring what the players height of jump should be based off of x-Time if button is held?

###
#2
Members - Reputation: **887**

Posted 28 August 2011 - 02:53 AM

Usually this is done per time step. In mathspeak: you integrate the equations of motion with explicit Euler method. So each time step you do:

So as long as there are no other forces and accelerations this will make the players movement approximate a parabola automatically.

acceleration = -g + other accelerations + Forces/m; velocity += acceleration*dt; position += velocity*dt;With dt being the time step. So if you want to jump you can simply modify the velocity value or add a force. Basically you do something along the lines:

if(button pressed) other accelerations = some value;You obviously still have to modify this so the player can't accelerate up by holding the jump button indefinitely.

So as long as there are no other forces and accelerations this will make the players movement approximate a parabola automatically.

###
#3
Members - Reputation: **550**

Posted 28 August 2011 - 05:25 AM

From Newton's equations of motion:

http://en.wikipedia.org/wiki/Equations_of_motion

So, si is your position on the current frame, vi is your velocity and a is your acceleration (gravity and other forces) and t is the time. Just plug in the numbers

Cheers, Paul.

http://en.wikipedia.org/wiki/Equations_of_motion

So, si is your position on the current frame, vi is your velocity and a is your acceleration (gravity and other forces) and t is the time. Just plug in the numbers

Cheers, Paul.

###
#5
Members - Reputation: **269**

Posted 29 August 2011 - 02:43 PM

Hey, thanks guys! I was way off on what I need to have been doing. I'll toss this in, and see if I need to do any tweaking. thanks again

You will need to do some tweaking. To the initial velocity of the jump or the acceleration due to gravity.