Ok so the question is simple. If you know the jump force, you know the gravity, and you know the velocity, can you map out the curve of a jump?

This is for a really simple patrolling/jumping AI critter… Very simply put, he walks back and forth, and uses a simple raycast to see if there is ground in front of him. If there isn’t, flip and reverse direction. SIMPLE and awesome! Weeeee!

Now the kicker, I want to make him jump from platform to platform. I’ve done this pretty easily by treating him like any other moving character. Setup a speed multiplier, assign a jump force (using Impulse, FYI), etc etc.

So I “map” out my possible jump like this:

If there is no ground in front of him (normally would just flip) I draw a ray up to what I calculate to be the Apex of the jump, then back down identically to the other side. If the second ray detects ground, JUMP (you have something to land on!). However, I am just using 2 straight lines, and it doesn’t seem to be too accurate.

I’m hoping someone has a reasonably simple way to graph out the jump, using Debug.linecast (or something visual in the scene view) so that based on the current velocity/gravity magnitude/jump force (again IMPULSE, I"m not even sure how Force works now that I’ve been trying impulse) you can see the curve of what the jump will be. Should be easy since we have basically all the variables, I’m just not sure of the formula. Here is what I have so far:

```
//The gravity magnitude
float grav = Physics2D.gravity.magnitude;
//our current velocity. Since there is no resistance, character should be able to move through the AIR at the same rate as on the ground right?
//So airborn velocity shoudl be the same as grounded velocity
jumpCheckDistance = Mathf.Abs(m_Rigidbody2D.velocity.x);
//How high can he jump? Basic formula (I think) of: Force squared * (gravity *2)
float jumpHeight = jumpForce * jumpForce / (2 * grav);
//Now set the points. jumpCheck (Vector3) shoudl be the APEX of the jump...
//NOTE: currentSpeed is the velocity, we simply multipy it by -1 if < 0 since we will be going the OPPOSITE way (flips the direction of the raycast)
//Also NOTE: foot is an empty game object i place at the bottom of the character to measure from the ground (for grounding and what not).
jumpCheck = foot.transform.position + (new Vector3 ((jumpCheckDistance/2) * (currentSpeed > 0 ? 1 : -1), jumpHeight));
//jumpCheckGround is the position of where he shoudl land based on the jump. Basically an identical line as the last, drawn from the apex down... the second half of the "bell curve"...
jumpCheckGround = jumpCheck + new Vector3 ((jumpCheckDistance/2) * (currentSpeed > 0 ? 1 : -1), (jumpHeight) * -1);
```

So this creates a fairly accurate representation of the jump, but it’s not totally accurate. Is there anyway to get this closer? Or rather, can anyone show me a formula to calculate the true apex of the jump, and the position of the landing (or really, I woudl like the whole curve, so I can tell where he will collide, etc)?

Let me know if this isn’t very clear, I’m a little rushed this morning. Thanks everyone!

Adam