Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I found this general question, but I'd like clarification on a specific point.

Consider this simple scenario:

  1. Client A sends input to move at T0.
  2. Server receives input at T1.
  3. All clients receive the change at T2.

With client-side prediction, client A would start moving at T0, client-side. All other clients receive the change at T2, so to them, client A only started moving at T2.

If I understand correctly, client B will always see client A's past position and not his current position! Is that supposed to happen? How can I sync those clients' world views?

share|improve this question

2 Answers 2

All clients are initialized to the server time when they log in or the game starts, they get updated on this occasionally.

The server uses the "keep alive" ping of the authentication service and lets the clients know what kind of delay they're working with, this delay will change over time and so needs updating occasionally. If you're not using a proper authentication service then the server manages the ping.

All clients know that they are acting "server time + delay" ahead.

Clients then can use this delay and their duplication of server time to properly interpolate forwards proxies from other clients' time and data from the far past so that other clients appear locally in the present on the player's Client, which is actually operating in the near future relative to the Server and that Server is itself in the near past relative to the remote Clients.

tl;dr Sync to server time, keep track of ping, interpolate all proxy clients.

Clear enough? =)

share|improve this answer
1  
And: you can't sync both clients completely unless you find a 0ms ping / break the law of physics. You'll always have a some delay and interpolation involved. –  Laurent Couvidou May 28 '12 at 21:33
    
Thanks for the lengthy explanation! I still don't understand this particular part: 1) Client A input "move right". He starts moving client-side. 2) Input goes to server, then to client B, x ms later. So, client B sees client A move only x ms later. If you put client A and B side by side, A would move instantly on his screen while on B's screen, A would move x ms later. –  Legendre May 29 '12 at 12:41
    
@Legendre Exactly. Remote players can't start to move instantly, nothing you can do about that. You can see this happen in all games where someone first moves or stops. However, for usual gameplay where people move continuously interpolation works pretty well. The point is that no one plays side by side and therefore no one ever sees all these tricks, all the players care about is if the other people look as if they move normally. In the end because you are developing side by side you are seeing a distorted view of what players see. –  Patrick Hughes May 29 '12 at 15:11
    
Oh see. Thanks. –  Legendre May 31 '12 at 6:56
up vote 3 down vote accepted

A better, and more direct, answer would be: They don't ever sync. When placed side-by-side, Client A will always move first, before client B sees him move.

"Tricks" are then used to resolve this difference. E.g. If one player shoots at another, resolve the shots based on what the shooting player saw, by checking for past positions on the server (Counterstrike etc).

Or, once client A starts moving on client B's machine, it is forward extrapolated in time, to show an "approximation" of where the player will be. New commands are still lagged though. (Tribes etc)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.