Question about Time.DeltaTime

In FreeCamera.cs (default template camera controller)
Time.DeltaTime is used inside OnFixedUpdate(), and it seems FlaxEngine does not have dedicated fixedDeltaTime inside Time class.

Is interval time of OnUpdate() and OnFixedUpdate() same, or that use of DeltaTime inside OnFixedUpdate was just tolerated?
AFAIK FixedUpdate is for physics update and not dependant to Update()'s render frame frequency.

1 Like

AFAIK FixedDeltaTime is simply the target frame rate you are aiming to have your physics simulate step at. In Unity they control this globally with a modifiable option and the engine calls FixedUpdate at this interval. What I have been doing and what I have seen others suggest doing in the Discord is to make your own constant that you use.
This would be [1 / <TARGET_FRAME_RATE>]. So somewhere in code do something like this for 60 FPS.
public const float FIXED_DELTA_TIME = 1 / 60f;
Then use this as your delta. You could also round this up to something more clean like 0.02f. I am still brand new to the engine so perhaps someone with more experience can chime in, but I have also seen people simply use Time.DeltaTime as well.

Based on the docs, it is unclear how the engine handles this and if it just runs at the same rate that normal Update does. I would also like clarification on this as well though.

But isn’t ‘1/Target physics framerate’ represents ‘current measured interval’? It does not have issue when physics loop finished less than targeted interval, but loop ‘tries to meet up’ when logic lags than 1/FPS.

Yes you are right. At that point you mine as well make your own update loop based on it.

After looking again it seems this is the best answer from a user named GoaLitiuM -

the actual value that changes every frame was collapsed into single variable instead of having different ones for fixed and non-fixed delta times
so in case framerate drops, the deltatime also changes
but yes the framerate can be changed in TimeSettings

This makes the most sense to me. So what you should use then is Time.DeltaTime.