- Home /
why unity official course use Time.deltaTime inside FixedUpdate
Here in this 2d platformer course he uses
void FixedUpdate() { velocity += gravityModifier * Physics2D.gravity * Time.deltaTime; }
why he uses Time.deltaTime inside FixedUpdate ?
as I read in other questions people answered no need to use Time.deltaTime inside FixedUpdate because it already has a same duration in all devices.
Answer by lonevetad · Oct 13, 2017 at 10:01 AM
It's used likely because you don't know the exact value Time.deltaTime holds at programming-time. Yes, documentation assures that it has the same values in all devices, but no one tells you the exact value to use in substitution, for instance "0.010 seconds", so its value is hidden. If this value would be constant, as it is, and publicly known and shown, so it would have been stored in a static const
variable, like "pi greek" in Mathf. So, I suggest to use the hidden and unpredictable variable to be flexible. I hope to be usefull.
Your answer
Follow this Question
Related Questions
How to instantly accelerate a falling game object to the maximum fall speed? 2 Answers
Restricting movement to one plane, but smoothly switching what plane that is 0 Answers
Rigidbody character and Update() function 1 Answer
How to get a few touches on sprites? 2 Answers
Change gravity on button 1 Answer