Improbable Icon

Is there a global time concept?



In many of my games I typically use DateTime.UTCNow for a baseline of what time it is. I then use TimeSpan to determine when events should happen. In SpatialOS, is there a concept of a global time that I can use?

For example, I want the player to get hungry over time. Currently I have a minute tick count and run a process in the background that deducts one point every minute. The issue is, I have no global way to do this. I expect that if a player hops back and forth between workers, the timing won’t be perfect as the minute will reset every time a worker takes over ownership.


I don’t think there is a global time concept that I have found. Suggestions from the past have been that you could spin up a worker that does nothing but keep track of the time. Then have your other workers or clients just do a query to that worker to grab the current time / sync up the time.


There have been topics in the past but simply put there is no global time concept; even worse: commonly cloud solutions can have up to 30 seconds drift between server, even when configured correctly. I recommend implementing your own ‘ticks’ system where you count small increments of time and update the state with your latest tick. (for example: have a tick every 5 seconds)

Even if you switch between servers the worst that can happen is that the player loses 5 seconds. For actions with real short intervals, you probably don’t want to care since crossing servers shouldn’t happen all that often and having an action ‘reset’ due to a switch is negligible.


I’ll chalk this up to a much desired feature… :slight_smile:


We implemented Cristian’s algorithm where we have “time server” entity and each worker syncs to on startup.

So far it’s working for us, we do a lot of extrapolation of simulatino state based on time and this is the backbone for all of it.

There are more advanced algos, such as NTP. We might move to more reliable versions later on.

  • Oddur, Klang Games


Thanks for sharing that! I think it will come in handy in my game as well :smiley: