Sign in to follow this  
KanonBaum

Smooth jumping arc

Recommended Posts

KanonBaum    277
I have this plat former boss and one of his AI patterns involve him jumping from one spot to another (I give it coordinates to the next destination).

Originally, the boss would just navigate his way to the point. I decided I wanted the boss to make a jumping arc over everything (i.e. jumping really high up) to land precisely at the next point.

My problem is that the x-speed is constant, so if it is a large distance, the boss would need to jump really high to make it. I can't seem to come up with the right design.

Originally, I was going to show you my original calculations but.... they're embarrassingly bad. I feel like some simple geometry or basic calculus concept will come into play here.

Thanks.

Share this post


Link to post
Share on other sites
beatlefan    198
You could just clamp the height of the boss jumps, and the height at which it clamps at could be dependent on the distance of the jump. Not the best answer I know, but it would work.

Share this post


Link to post
Share on other sites
HappyCoder    5052
You could have it follow a parabola.

Y = Y[sub]0[/sub] + V[sub]y[/sub] * t + 1/2 * g * t ^2
X = X[sub]0[/sub] + V[sub]x[/sub] * t

Those two equations define the parabola

Y[sub]0[/sub] is the starting y position
X[sub]0 [/sub]is the starting x position

g is the amount of gravity you want to apply to your system, you can adjust this until it looks right
t is time in seconds
V[sub]y[/sub] is the staring Y speed
V[sub]x[/sub] is the string x speed

From this you could create a nice curve.

You can either define how much time you want the object to travel or the initial x speed, either one will be enought to define the curve.

Hopefully this is enough information to get you started. Google around and you can find more info, or if you need further clarification I can explain a bit more.

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