Why does fixed Timestep affect deltatime in Update?

I am using

Debug.Log("Update time :" + Time.deltaTime);

in Update() to get the time between each frame. (Not fixedUpdate)

When the timemanager is in default settings ( Fixed Timestep = 0.022 / Maximum allowed Timestep = 0.022) then I get values that I am expecting ( Varying deltaTime at each frame around 0.0164 s )

However when I change Fixed timestep to 0.0083 AND Max. allowed Timestep to anything smaller 0.016 (i.e. the frame rate that I normally get) then Time.deltaTime returns the value set for the Max. allowed Timestep.

Looking at a wealth of other questions and the manual I expected the timestep to have no effect on what Update does. But I was wrong.

So why is that? Is the deltaTime set somewhere that is specific to how long the physics are allowed to run for? Have I misunderstood something? Or have I made a goof somewhere?

EDIT: TL;DR ANSWER (by @Bunny83):

Maximum Allowed Timestep is the upper limit that time.deltatime will report.

If a frame update takes longer than
Maximum Allowed Timestep to process,
the physics engine will “stop time”
and let the frame processing catch up

This page explains it all.

Max allowed TimeStep pretty much specifies the minimum allowed FPS under the condition of a heavy FixedUpdate, like if you have heavy physics. Setting such a low FixedTimeStep makes FixedUpdate run a lot.

I believe you are telling it :

Attempt to run FixedUpdate 120 times a
second but only allow FPS to drop to
62.5 as a result.

62.5 is a decent target, but the fact that your FPS is being throttled down to your MaxAllowed defined FPS could indictate that your FixedUpdate is doing too much work.

I’m not sure when you modified your default settings but in my Unity the default settings are:

0.02 Fixed time step
0.333333 max allowed time step

First of all the fixed time step defines how many physics frames you get per second. The default setting is 50 frames (1 / 0.02 == 50). the max allowed time step is not related to one physics frame but to your whole game performance.

Time.deltaTime when read outside FixedUpdate simply returns the time one game frame took in total. So if you get a value of 0.0164 that means you have a frame rate of about 60 frames per second (60.9756…).

When you decrease the fixed time step to “0.0083” that means you increased the physics frame rate up to 120 fps (120.4819…). The physics frames are part of your whole frame time. The more physics frame you have per second the more time it will require from your game frame time. with 120 fps fixedupdate and 60 normal fps you get about 2 fixedupdate calls in one frame. If you do heavy things in FixedUpdate your game frame rate will suffer.

The max allowed time step is just a security cap to prevent a down spiral. Each frame Unity’s physics system tries to “catch up” with the normal game time. It does that by running several physics steps in a row until the physics time is equal or greater than the normal game time. That way Unity ensures that the same amount of physics frames are executed in one second. Howeever if one physics step takes too long the over all frame time will get longer. Therefore you get a lower fps. However that means since you have less Update calls, Unity has to execute more FixedUpdate each Update to get to it’s 120 frames per second. So if the framerate drops to 30fps Unity will execute 4 fixedUpdate each frame which might cause the frame rate to drop even further. This could go forever until a single frame takes 10 seconds and unity will have to call 1200 fixedupdates per frame and it would get worse and worse. The max allowed timestep simply caps the over-all frame time to usually 1/3 second so it won’t get worse than 3 frames per second.

If you set the max allowed time step to 0.016 that would mean as soon as your frame time takes longer than this your frame time is capped to that value and it will stop calling fixedupdate until the frame rate “gets better”. However 0.016 equals 62 frames per second. You probably have v-sync on so your framerate is limited by your monitor’s update rate of 60Hz.

You really shouldn’t mess with the max allowed timestep. If it’s too low your physics calculations will go wrong as Unity will simply skip physics frames.