Jump math

Started by
3 comments, last by sooner123 12 years, 7 months ago
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?
Advertisement
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:

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.
From Newton's equations of motion:

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


[font=sans-serif][size=2]30fb2177720aadbd32ef942603af26aa.png[/font]
[font=sans-serif][size=2]
[/font]
[font=sans-serif][size=2]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 :)[/font]
[font=sans-serif][size=2]
[/font]
[font=sans-serif][size=2]Cheers, Paul.[/font]
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

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.

This topic is closed to new replies.

Advertisement