Sorry for my English.
I have developed a client-server game on Unity and I need equal time counters on the client and server for synchronization. On the server side (Java) all is working fine.
On the client I tried to set Fixed Time-step to 0.001 and count time on FixedUpdate. It works, but in one thread with other scripts and sometimes lags. I became convinced of this in this article
Also I tried to count time in other threads, but this code gets wrong time (I tried TICK_TIME 1 and 5)
while (started)
{
time += TICK_TIME;
Thread.Sleep(TICK_TIME);
}
How to realize stable counter? And is it possible in Unity?
http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch%28v=vs.110%29.aspx
var watch = Stopwatch.StartNew();
//Do work
Console.WriteLine("Time elapsed: {0}", watch.ElapsedMilliseconds);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.