Adding TimeDelta to torque for fps independence?

Would it make sense to add the Time.deltaTime to the AddTorque function like

rb2d.AddTorque(torqueAmount * Time.deltaTime);

to make this frame rate independent and have similar rotation behaviour at different computers?

Hi grr,

Welcome to our community! :slight_smile:

That’s a good question. Actually, the rigidbody object takes care of the framerate as it is part of the physics simulation which is framerate-independent. So, no, do not use Time.deltaTime with the rigidbody.

If you experience problems with the rotation, move rb2d.AddTorque(torqueAmount) to the FixedUpdate method. The user input must be checked in Update, though.

Did this help?


See also:

1 Like

There rotation works fine, its just that the addTorque with a value of 10 for torqueAmount as in the video rotates the snowboarder only very slowly (on a low end machine) where a value of 150 fits better. Testing the game on a high end machine makes the player rotate too fast now, but adding the timeDelta constant makes the rotation speed constant for both machines.
Doesn’t the fps dependent Update() adds more torque the more fps a computer has.

move rb2d.AddTorque(torqueAmount) to the FixedUpdate method. The user input must be checked in Update, though.

So add a constant to check from Update() for keypresses, but update the AddTorque in the FixedUpdate method depending on which constant is set?

Exactly.

Not a constant, though. A variable. :wink:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms