Setting Time.timeScale during FixedUpdate and having it immediately take effect

This is a pretty niche problem: when you set Time.timeScale, the change does not actually take effect until the next Update loop. So if you want to pause your simulation on fixed update #101, and your timeScale is set such that you run 100 fixed updates per Update loop, setting Time.timeScale in fixed update #101 will actually only take effect after the remaining 99 fixed updates run (and Update is executed again).

I’m guessing this is probably due to some pretty low level stuff in Unity, but wondering if there is a possible workaround (the use case is for a replay system, to fast forward ultra quickly to specific frames).

Thanks,
Erik

This seems by design, and I can’t figure out a proper workaround. If this is related with physics, you may gain better control by disabling Physics.autoSimulation and calling Physics.Simulate explicitly. This way you could specify exactly when and how each physics step is performed.

1 Like