Sign in to follow this  

Realistic Jumping Physics [RESOLVED]

This topic is 4378 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to be able to do realistic time based jumping physics, with air resistance. And I know that mass is cancelled out in the actual equation, but I also want to be able to somehow, allow heavy sprites to not jump so high, and light sprites to jump high. Any ideas on how I can pull this one off? [Edited by - Jacob Roman on December 17, 2005 2:21:14 PM]

Share this post


Link to post
Share on other sites
Think about how the jumping begins. A force is applied, and this causes the object (animal, human, whatever) to accelerate upwards. The acceleration is given basically by force = ma, that is, acceleration = force/mass. So, applying the same force to a more massive object results in less net acceleration. Less acceleration means a lower velocity is achieved. Once the applied force stops---feet in the air, only gravity applies. The rest of the jump is just deceleration by gravity and falling back down. If starting the freefall portion from a lower after-acceleration velocity, then the height reached in the jump will be less. So...it can be handled naturally I think.

Share this post


Link to post
Share on other sites
So I divide the inverse of a constant initial velocity by the sprites mass? Seems to make sence. Like if 10 were the constant initial velocity, and mass were 100

Inverse_v0 = 1/10 = .1
.1/100 = 0.001

But when the mass is 10:
.1/10 = 0.01

...the initial velocity is greater.

Share this post


Link to post
Share on other sites
I would say that u could model something like that by giving urself and initial velocity and then use F=ma formula to find out ur accceleration down and then do something like this:
x=xoriginal +Voriginalt+1/2at^2
Note this is clean physical stuff that i got from a book that i bought(Haliday and resnick or something like that), and if it is any good for modeling i am not sure but i would think you could make it work, btw i am new at this so take this info with some salt as i might be wrong.
Also you could make ur initial velocity dynamic once again using the F=ma formula and then just getting the veolocity of the object under acceleration.

Share this post


Link to post
Share on other sites
Really, grhodes_at_work is giving you the right idea. If you treat jumping as the application of an initial impulse J, then you can arrive at an initial velocity v0 like this:

F = m * a -> a = F / m
if the impulse of jumping is J, then F = J.
a = J / m;

But because this is a very simplified example of impulse, we can disregard the equation:
v = v0 + a*t = (J / m) * t
Instead, assume that v = J/m.

After the initial application of impulse, use the proper equations:

F = ma = mg = -9.8*m
a = -9.8;

v = v0 + a*t = (J/m) + -9.8*t;

or
v = J/m;
v += -9.8*t;


This will produce shorter jumps for massive objects, and higher jumps for less massive objects when the same impulse J is applied.
HTH

edit: I should note that -9.8 for g is meters per second squared.

Share this post


Link to post
Share on other sites
This is a case that is best treated as an impulse (rapid application of force). In this situation, we'll treat impulse as instantaneous application of force. This means that the force is applied as the initial situation, and then the object is advanced as usual from there.

The application of this force will cause an instantaneous acceleration of F/m (or specifically, J/m). An instantaneous acceleration applied to a vertically stationary object (v0=0) yields an instantaneous vertical velocity of J/m. From then on, we can treat v0 as J/m, yielding the equation I submitted.

Share this post


Link to post
Share on other sites
Awesome, I got it now!

I had these variables setup when the program loads:



p.X = 150 'X Position
p.Y = 200 'Y Position
p0.Y = 200 'Initial Position
f = 50 'Force
m = 10 'Mass
v0 = f / m 'Initial velocity
a = -GRAVITY 'Acceleration






Then in the game loop, I did this:



Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = vbKeySpace And Jump = False Then

Milliseconds = Get_Elapsed_Seconds

Jump = True

End If

End Sub

Private Sub Timer1_Timer()

Cls

If Jump = True Then

If p.Y > p0.Y Then

p.Y = p0.Y

Jump = False

Else

t = Get_Elapsed_Seconds - Milliseconds

v = v + (v0 + a * t)

p.Y = p0.Y - v

End If

End If

Draw_Sprite

End Sub




Thanks everyone! Problem is resolved!

Share this post


Link to post
Share on other sites

This topic is 4378 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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