M
M
MishkaVNorky2019-03-18 10:37:10
C++ / C#
MishkaVNorky, 2019-03-18 10:37:10

UTC server time and working with it in Unity?

Hello.
Maybe someone came across. For a mobile game, you need to get the time from the server and spin it in Update.
Game events will be tied to the time, the time will be saved in a file.
They also use PlayFab and Unity IAP.
Questions:
1. What is the best way to do it?
2. From which server did you take the time? In addition to my
3. And most importantly, I get the time from the server in UTC form, how to correctly increase it further in Unity? And at the next entry, I also synchronize it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shai_hulud, 2019-03-18
@MishkaVNorky

1) Do not use real time, use relative time from any point: for multiplayer, the time of project creation, for singles, the time of account creation. All temporal processes in relative time, it will be possible to guarantee that the relative time always grows and there will be no time out of sync.
2) It is better to take from your own.
3) add Time.deltaTime every Update and only positive values.
Relative time bonuses are that when a player logs in, you can correct the time out of sync:
a) the player was ahead of the server by 5 seconds, logged in a day after offline, add him = 1d. - 5 sec.
a) the player was 1 minute behind, entered 5 seconds after offline, add him = 1 minute. + 5sec.
well, no problems with serialization, storage, time zones, etc. relative time can be a simple number (ticks) or TimeSpan.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question