Time, Which one should I use?


So currently I have most things in my game running on deltatime which is great because I’m trying to be able to pause the game. Simply by stopping time, everything is put on hold. I plan to stop time for my General Esc menu as well as the Character and Inventory screens.

The problem is, there are some things i’d like to do in the menu that require use of time as well. Animations and movements and such, that are basically disabled with the halting of deltatime.

I’ve looked in the scripting api and I’ve got to say, the time descriptions are about as ambiguous as it gets. Can anyone make a programming suggestion for me?

You should use Time.realtimeSinceStartup.


The real time in seconds since the
game started (Read Only).

In almost all cases you can and should
use Time.time instead.

realtimeSinceStartup returns the time
since startup, not affected by
. realtimeSinceStartup
also keeps increasing while the player
is paused (in the background). Using
realtimeSinceStartup is useful when
you want to pause the game by setting
Time.timeScale to zero, but still want
to be able to measure time somehow

Note that realtimeSinceStartup returns
time as reported by system timer.
Depending on the platform and the
hardware, it may report the same time
even in several consecutive frames. If
you’re dividing something by time
difference, take this into account
(time difference may become zero!).

There is Time.realTimeSinceStartup which is totally unaffected by the current timescale. This is probably what you’re looking for!