Greetings;

I’m making a temple run type game. The players speed gradually increases. My problem is, I want the jump distance to be the same even if the forward speed is multiplied. For instance, if the player gets so fast, they could jump over 5 platforms, or 10 if I wasn’t able to accomplish this.

Currently, for each time the forward speed is increased, I increase the gravity by a variable that I’m playing with, but I still havn’t found the right amount. My tests are either too much gravity or too little gravity.

ForwardSpeed = 2

Gravity = 1.5

(increase speed here)

ForwardSpeed = 3

Gravity = 2

How do you think I can achieve the same jump distance? Is there some type of equation I could use to make this happen?

I’ve seen this one before. It’s a bit trickier than it looks. Remember, if you increase gravity then the jump will have a lower trajectory, even if you get the distance right.

To have the same jump arc at higher horizontal speed you must modify both gravity and initial upward speed.

Been forever since I did this, so I’ve lost the base maths, but from my on code, looking back…

- Take max height of the jump as a constant . (In meters)

2. Take normal jump distance (on the flat) as another constant [D]. (In meters)

3. Time (In seconds) to spend in the air [T] = current horizontal speed (In meters per second) divided by [D].

Gravity (in meters per second per second) [G] = (2*H)/(([T]/2)^2)

Vertical jump speed (In meters per second) [V] = [G] * [T]/2.

Hope this helps. (Hope I’ve read my old math notes & code right (I was a lousy commenter back in the day).