   how to synchonize the time between client and server
  Hi all  I am new in online game. just a question, have read some articles about prediction and latency. they all mentioned that send the time(t0) that action was performed to the server from client. latency time t1, server process the message at time t2. client pos = v*(t2-t0+t1). My Question is how to synchonize the time between client and server?????   
  Here's the simplest method, which works well enough:Put a timestamp in each packet that the server sends to the client.The client records the client time at which the server packet was received.This gives the client an offset: server time at client clock.Because of jitter, that offset will vary slightly over time, so you typically want to use a leaky integrator (smoothing average) for this offset over time.Additionally, if you measure round trip, you may want to add half of the round trip to the server time estimate.Note that time is not so much about exact synchronization (a la NTP); instead, it's about making sure that you order events along some monotonically increasing timeline.;  thanks very much mate!Quote:Additionally, if you measure round trip, you may want to add half of the round trip to the server time estimate..can you explain more about it?  what do you mean by that?Quote:Note that time is not so much about exact synchronization (a la NTP); instead, it's about making sure that you order events along some monotonically increasing timeline.example?;  It's essentially impossible to have your client and server perfectly synced.  So don't even bother.What's important is that they have some common idea of time that's at least relatively in sync.  So that the server doesn't just say "spawn rocket now," but rather says "a rocket was spawned at time t at this location."By having a common understanding of time, and referring to events as happening at a particular time, the separate simulations on the client and server can remain relatively in sync, and then be corrected as you go on.   ;  The Forum FAQ has more pointers about time and clock management in distributed simulation (which is what networked games really are about).;  thanks alls   ;  i seem understand the theory. if imagine the client is in different time zone, let's say 9 am, but server is now 11pm, how to make they to have same heart beat??can anyone give me a logic, like skeleton code.thanks   ;  All that matters is relative time. Their own local time is irrelevant. You can measure time relative to the start of the game, or a previous message.   