Fixed update isn't time scaled, right?

I’m trying to track down a bug with my menus after switching to the new input system. I honestly cannot fathom how this is occurring, unless… is FixedUpdate influenced in any way by changing the time scale?

I was under the impression that it was not, that when I set Time.timeScale to 0 I still get fixed update called at the same regular intervals. (After all, update isn’t impacted by the time scale.)
Is this how it works, or not?

The only way I can determine the source for the bug I’m seeing is if fixed update isn’t getting called while the game is paused.

Fixed update is indeed time scaled. Simple enough to test, just set the time scale to 1/100th and print something every fixedupdate.

2 Likes

Uhhhg, I was NOT expecting that. I don’t think that was ever explained at any point where someone was explaining the difference between Update and FixedUpdate. This isn’t even mentioned in the scripting API. That information could have saved me a LOT of struggle.

Well, thank you for the response.

It is mentioned here: Unity - Scripting API: Time.timeScale

But it is not mentioned in FixedUpdate documentation.

2 Likes

I love this about Unity3D. I usually spend a minute or two looking up an API, then when I find it I spend a few more minutes testing it. Saves so much headache of going down the wrong path and finding out “Oh man, that won’t do it.”

As for your specific issue @Marscaleb , I believe the thinking behind the physics on fixed update idea is no matter how bad or good your performance is, the physics simulator will execute an exact number of updates per passing notion of “Time,” and since Time can be scaled, you get what you saw.

One way to handle it is to adjust fixedDeltaTime at the same time as you slow other stuff down.

Here in a super-handy timing diagram:

Doesn’t explicitly answer your question, but good stuff to know and have at your fingertips. Unity is really freakin’ awesome with all the stuff it does, but it isn’t magic. It still runs on a CPU in the real world.

Well I got around the issue I was having by copying a bunch of code to a LateUpdate function instead.

Normally this isn’t an issue; the stuff I normally put in FixedUpdate are part of the things I want to be “paused” when the game is paused. so I never gave it a second thought.
This just came up with switching to the new input system. Without going into to many details, I had some calls balanced out with commands I put in FixedUpdate. But since I still need input when the game is paused, well, there were problems.

1 Like