I’ve seen many different answers online and all of them never giving a full reason on way you should or should not. The question is in thee title, Should you use Time.deltaTime in FixedUpdate().
You should use Time.deltaTime everywhere, unless you need to consult the actual physics update rate. Time.deltaTime returns the proper value depending where are you reading it from.
For reading the delta time it is recommended to use Time.deltaTime instead because it automatically returns the right delta time if you are inside a FixedUpdate function or Update function.
Time.deltaTime is the time between last frame. Inside FixedUpdate() this can sometimes cause odd behavior depending on the load running in any given frame and give unexpected results. Though I have never seen this. lol.
Unity recommends using Time.fixedDeltaTime in FixedUpdate() to help keep the behavior consistent.
After reading @Edy 's answer, I had to do some tests. Here’s the results:
(AvC is a poor man’s outlier elimination: it removes the smallest and largest values, then averages the remaining values)
As you can see,
deltaTime fluxuates in
Update() but always returns
fixedDeltaTime always returns
0.02 no matter where it’s called. This leads me to believe that
fixedDeltaTime is a setting rather than a reading of how long the last frame took.
Based on these results, it looks like you can use either one in
FixedUpdate(), although Unity does recommend using
deltaTime there too.
But most definitely, you should use