Lag Compensation

I’ve been working on a little multiplayer game based on Valve’s Source Multiplayer method (Described here: and I’m coming across an issue which someone asks on the page, but no answer is presented. I was wondering if anyone here could help me answer it. The question is as such:

[quote]From the page: After 100 milliseconds, the client will receive the server snapshot that contains the changes based on the user command he predicted earlier.
After 50 milliseconds, though, the client will receive a server snapshot that does not yet contain the changes based on the user command. Does the client simply ignore this snapshot? If so, what are the rules governing this?
In my case, this causes a stuttering when players let go of a movement key. Any help? I can provide some code if necessary, however, I think this is more of a conceptual issue than code issue.

If you try to predict the movement of objects you get the problems you worry about. It’s fairly easy to assume that objects will continue at the same speed, but this causes big problems when there are sudden changes. If you have a player standing still and then suddenly start moving, the message that s/he started moving will be delayed meaning that when the other players receive this message he’ll suddenly snap to his predicted position. The same problem happens when the player stops, at which point the extrapolated player will suddenly teleport back to where he stopped.

Valve don’t extrapolate positions. You will be displaying a delayed version of the world if you use interpolation, which is the standard nowadays. In this case you simply try to make sure that the world (other players, physical objects, etc) look smooth by interpolating between the state you get to reduce stuttering. All objects will be delayed by the ping, but at least they’re 100% smooth. I believe I read somewhere that the Battlefield games use interpolation for twitchy character movement, but extrapolation when dealing with vehicles because they simply can’t change their speed quickly and mostly just continue in the same direction they’re going.

However, each client is a bit flexible when it comes to their own players. When you move in the source engine the game sends a movement command to the server, but the game moves your character immediately without waiting for a response. As long as the player isn’t too far away from the last confirmed position from the server, the client is allowed to move things before getting confirmation. So the client doesn’t ignore the server when it says where the player is, but it doesn’t enforce it completely to reduce perceived lag. If you’ve ever heard of “rubberbanding”, it happens when the client and the server disagrees and the player is suddenly snapped or slowly pulled to his correct position. Most games are simple enough that this never happens unless your ping is fluctuating a lot.