Test if Jump can reach target

I have an object that can jump.

When it jumps, its Y velocity becomes -600 (pixels/second).

For up to .2 seconds, it can ignore gravity.

After .2 seconds, it begins to accelerate downward at 2100 (pixels/second).

Independently from its Y velocity, the object can move on the X axis up to 220 (pixels/second) or -220 (pixels/second).

How do I calculate whether or not, with a given starting x/y coordinates it can jump to a target x/y coordinate?

Also, how do I calculate the necessary X velocity to reach its target in the proper amount of time so that it doesn't overshoot or undershoot?

• Why is the speed to the left different from the speed to the right? – Peethor Dec 28 '15 at 6:25
• Also, I assume the downward acceleration is 2100 pixels per second per second? – Peethor Dec 28 '15 at 7:20
• have a look at this link – Hamza Hasan Dec 28 '15 at 9:41
• @Peethor Sorry, the discrepency between left and right movements was a typo, I corrected it. And yes, the downward acceleration is 2100 px/per second^2 – TheBroodian Dec 29 '15 at 0:45

You can find both at the same time:

• Pre-calculate a jump curve at maximum X velocity (blue curve)
• intersect the approximated curve on the downward side where the target platform height is the same (red dotted line)
• if the platform is further than this you can't make the jump
• scale down the curve on the X axis to match the X of the target (cyan arrow)
• that scaling applied to max X velocity gives you the needed X velocity to reach the platform in a nice arc. If you want different possible jump heights you can calculate a few different curves and pick the best one.

You may want to add another step to check for collisions, eliminating from the list of possible trajectories.

The jump curves don't need to be calculated every time, you can generate them once when the game starts.

This applies to 3D just as easily.

Can be extended to handle double-jumps and other variations.

If X speed varies during the jump it'll require a bit of adjustment but given enough of a margin it might not matter.

• Thank you so much for your answer, although I'm trying to find a way to express this algebraically because I'm trying to use this for AI to calculate whether or not a jump is possible, and then at what Xvelocity they will have to jump to reach desired platforms. – TheBroodian Dec 30 '15 at 2:36

You can calculate limits of your movement with these two formulas:

Maximum Altitude (Ymax) = (Initial Y velocity)^2 / 2*(gravity)

Maximum Reach (Xmax) = (Initial X velocity) * 2 * (Initial Y velocity) / (gravity)

• Just to be pedantic, it doesn't accelerate upward when it ignores gravity. Because what I'm stating by that, specifically, is that for up to 0.2 seconds there is no acceleration, or change in velocity. The initial acceleration is the jump itself, the acceleration would be the active force on gravity on the jumping object, causing alteration to its velocity. – TheBroodian Dec 30 '15 at 2:26
• Force applies acceleration to an object. When the object jumps (as described in the OP), no force is applied to it upwards. Rather, its upward velocity is immediately modified to a value. Assuming no other forces are present, no gravity means no downward acceleration for the initial .2 seconds of the jump. This means the velocity is constant, as the velocity of any object would be in a forceless vacuum (as opposed to accelerating in any direction, like you said). – Garrett Gutierrez Oct 10 '18 at 13:26
• @S.TarıkÇetin, you are probably confusing velocity with acceleration. There is a constant velocity upwards with no gravity (assuming an upwards initial velocity), but no constant acceleration. No forces = no acceleration. – Garrett Gutierrez Oct 10 '18 at 13:28
• Yes, I appear to have misinformed people. I edited my answer and removed the incorrect comment. My apologies about the inconvenience. – S. Tarık Çetin Oct 10 '18 at 16:34