0
\$\begingroup\$

I would just like to know if there is a way to work out the distance of a jump depending on how fast the player is going. For example if the player has a velocity X of 10 and he presses the jump button he should jump further than if his X velocity was, say 4.

I have a working jump mechanic that when the jump button is pressed the velocity is set to a predefined value like -10; Then slowly gravity brings it down but I want it to feel more realistic by applying the jump distance according to his speed

Any way to implement this?

\$\endgroup\$
1
\$\begingroup\$

If you're using velocities for this, the "jump distance" will be handled automatically. The distance on the X axis traveled during the jump is the product of the time in the air, and the X axis velocity. Say your jump takes one second to complete. If your character is traveling at 10 units per second on the X axis, during that one second jump, they will have traveled 10 units. If their speed is 4 units per second on the X axis, they will have traveled 4 units during the jump.

If you're experiencing otherwise, make sure you're maintaining the X velocity when changing your Y velocity for the jump.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.