How to sync client and server at the first frame

Posted by wheelinlight on Game Development See other posts from Game Development or by wheelinlight
Published on 2014-08-15T06:47:29Z Indexed on 2014/08/18 16:48 UTC
Read the original article Hit count: 245

Filed under:
|

I'm making a game where an authoritative server sends information to all clients about states and positions for objects in a 3d world. The player can control his character by clicking on the screen to set a destination for the character, much like in the Diablo series.

I've read most information I can find online about interpolation, reconciliation, and general networking architecture (Valve's for instance). I think I understand everything but one thing seems to be missing in every article I read. Let say we have an interpolation delay of 100ms, server tickrate=50ms, latency=200ms; How do I know when 100ms has past on the client? If the server sends the first update on t=0, can I assume it arrives at t=200, therefore assuming that all packets takes the same amount of time to reach the client? What if the first packet arrives a little quick, for instance at t=150. I would then be starting the client with t=150 and at t=250 it will think it has past 100ms since its connect to the server when it in fact only 50ms has past.

Hopefully the above paragraph is understandable. The summarized question would be: How do I know at what tick to start simulating the client?

EDIT: This is how I ended up doing it: The client keeps a clock (approximately) in sync with the server. The client then simulates the world at

simulationTime = syncedTime - avg(RTT)/2 - interpolationTime

The round-trip time can fluctuate so therefore I average it out over time. By only keeping the most recent values when calculating the average I hope to adapt to more permanent changes in latency. It's still to early to draw any conclusion. I'm currently simulating bad network connections, but it's looking good so far.

Anyone see any possible problems?

© Game Development or respective owner

Related posts about networking

Related posts about synchronization