2DPlatformer-Tutorial icon indicating copy to clipboard operation
2DPlatformer-Tutorial copied to clipboard

Player jump height changes based on frame rate

Open tqwewe opened this issue 3 years ago • 1 comments

The player jumps much lower when the frame rate is limited compared to when it's unlimited.

How can I ensure the jump height does not change based on the frame rate?

tqwewe avatar Feb 19 '22 14:02 tqwewe

You have to calculate vertical movement twice, before and after Move().

Something like this:

velocity.y += gravity * Time.deltaTime / 2.0f; controller.Move(velocity * Time.deltaTime); velocity.y += gravity * Time.deltaTime / 2.0f;

I recommend to use this method every time you have to calculate acceleration/deceleration.

Cheers!

nandovilla avatar Dec 21 '22 15:12 nandovilla