What exact value does Time.deltaTime supply?

I am trying to make my games framerate independent and of course i was referred to Time.deltaTime.

What I understand is that deltaTime will give me the time that the last render has taken, therefore making me able to adjust changes based on the time passed.

What i need to know though, is if this “passed time” is actual, real world time or physics simulation time or maybe even the amount of expected update cycles per second or any variation of these.

Here is why i do not understand it / need to know more about this:

People always describe that 60fps would give you the same movement speed as 200fps if the fps fluctuate. Thats fine.
But as a simple example, imagine a game where you are a bird and you may flap your wings only once every second. To make that one second regardless of my target platform (might be 60fps or 120 for example), I would use deltaTime.
Now you open up some CPU intensive program in the background and your fps plummet to 1fps. Of course when I can only display 1 frame each second, i expect the physics and everything to run slower as well, or else it would turn merely annoying stuttering into unplayable game jumps, as i cannot be expected to react to a game world that runs at “real time” while I can see only one frame per second of it.

If deltaTime delivers “The time in seconds it took to complete the last frame”, as stated in the documentation, would that not mean that my bird can now flap its wings every frame, which might be only a fragment of a second in physics time? Would that not allow me to cheat by slowing down my computer? And would that not break any game most of the time when the framerate drops below playable values?

While writing this I realized what I would like to get from deltaTime is the amount of physically simulated time since the last call to update. So is it that what it gives me, or is it the actual time since the last render, which would be kind of strange for the reason described above?

Time.deltaTime gives you the time in seconds since last update.

E.g 60fps ~ 0.016, 30fps ~ 0.033.

Sample use case: position += speed * Time.deltaTime.

The problem with your reasoning is that you assume a game that is running at 1fps should be playable.

No, because of Maximum Allowed Timestep in the time manager. But yeah, nobody’s going to play a game running at 1fps.

–Eric

I don’t think it should be playable, I just think it should not allow me to cheat by making the fps drop :slight_smile:
The Maximum Allowed Timestep sounds like something I should look into though, thanks.

Concerning npsf3000s comment “The problem with your reasoning is that you assume a game that is running at 1fps should be playable”, does this mean that what is happening is that the game logik will not slow down when the fps drop but instead it will simulate a full second in one frame?

No, the Maximum Allowed Timestep setting will make the physics simulation slow down.

–Eric

OK then, thanks.

It’s important to note that this applies [according to the docs] only to FixedUpdate and Physics… not to normal Update.

A good read:

http://docs.unity3d.com/Documentation/Components/class-TimeManager.html