I'm working on a networked game for a while. I'm aware of client-side prediction and lag compensation (shooting) but I'm not sure about entity interpolation client-side. I'm sending update/sync packets at 10fps from server and client interpolates from current position to newly received position. Interpolation takes 100ms (because of 10fps) to reach target position but what if new position arrives late or 2-3 packets drop? There will be no target position and sync'd (client-side) entity will be idle until new position packet but entity continuously moving forward server-side. Basically, I don't know what to do in this situation.


The point of interpolation is to take the last received position from the server and predict where the object should be now based on how long ago the last packet was received.

This is called "linear interpolation" as we assume that the object moves at a constant, fixed velocity based on the motion vector last received from the server. There are problems with this when a true disconnect occurs (if you've played Second Life for any period of time, watching yourself suddenly go flying through walls and off into the void is the result of client-side linear interpolation with no resync from the server).

This is a decent article on how to go about setting up interpolation and resync in unity. It's a little above my head to try and provide a summary, but it has to do with storing input, acting on it immediately on the client, then when the data is sent to the server and validated, some computation is performed on the reply back to the client to keep things in synchonization.

  • \$\begingroup\$ I'm already re-applying inputs on the client when server sent sync for itself. For entities (other players, projectiles etc.), you suggest to keep moving with currenty velocity (predict) until new server sync arrives, right? \$\endgroup\$ – M. Fatih Jan 25 '16 at 16:03
  • \$\begingroup\$ @M.Fatih Yes. The prediction will keep objects moving until you get another sync. \$\endgroup\$ – Draco18s Jan 25 '16 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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