Sign in to follow this  
doyleman77

Jump math

Recommended Posts

doyleman77    367
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?

Share this post


Link to post
Share on other sites
japro    887
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:
[code]
acceleration = -g + other accelerations + Forces/m;
velocity += acceleration*dt;
position += velocity*dt;
[/code]
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:
[code]
if(button pressed)
other accelerations = some value;
[/code]
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.

Share this post


Link to post
Share on other sites
wildbunny    550
From Newton's equations of motion:

[url="http://en.wikipedia.org/wiki/Equations_of_motion"]http://en.wikipedia.org/wiki/Equations_of_motion[/url]


[font=sans-serif][size=2][img]http://upload.wikimedia.org/math/3/0/f/30fb2177720aadbd32ef942603af26aa.png[/img][/size][/font]
[font=sans-serif][size=2]
[/size][/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 :)[/size][/font]
[font=sans-serif][size=2]
[/size][/font]
[font=sans-serif][size=2]Cheers, Paul.[/size][/font]

Share this post


Link to post
Share on other sites
sooner123    269
[quote name='doyleman77' timestamp='1314557510' post='4854788']
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
[/quote]

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this