# Jump character using Sine Curve

I have a character in the game that needs to jump on a certain input (up arrow).

Since it is an endless runner game the player is continuously moving forward. The player should jump a particular specified distance using sine curve.

Eg : Assuming jumpDistance = 15;
If the player starts jumping at position(z axis) 10 then the player should jump and land at position 25 using sine curve.
Also the player has a Rigid body component attached with gravity set to true.

The player speed increases gradually but the jump arc should remain the same throughout the game and jump animation should end exactly while landing to ground

How can this Jump using sine curve be implemented so that curve remains the same and distance specified is covered and also the jump animation to end exactly at the time of landing.

The moment you press jump, you need to save the current x and y. From there, it’s just calculating the current sine based on the traveled distance times. the x movement dictates the y height. Just divide the traveled distance since the jump as pressed by the distance you want to go with your sine and you have a scaler of 0 to 1. times 2 minus 1 and it’s -1 to 1. now calculate your sine and multiply that with your jump height that you add to the base height got got from starting the jump.