I have been reading about client-side prediction lately and I have been thinking of ways to implement it into my multiplayer game. I think I have a pretty good understanding of client-side prediction but I am a bit confused of how packet loss will affect it.

For example, say the client moves left. The client moves left on its side and also sends a packet to the server. If the server received this packet, it would see it was a valid move and send a packet back validating the clients decision. But if the packet didn't make it, the server would not move left and if the client moves left again their move will seem invalid to the server, giving the client a choppy experience.

So my question is how is client-side prediction implemented without this problem? Thanks for your help.

  • 1
    \$\begingroup\$ The real answer is that packet loss will always cause an issue. For realsies, there's no magic solution to fully mitigate this, you're always going to have problems with packet loss. \$\endgroup\$
    – user39686
    May 24, 2014 at 23:30

1 Answer 1


Important commands need to be reliable. If you have some input, you need to do get it to the server. If the packet is dropped and not ACKed, you must resent it.

This is one reason that less twitchy games often just use TCP (with NAGLE off). Games that need UDP often end up having to reimplement much of TCP for some types of messages.

For instance, you can ACK every packet received all the time. If a packet is not ACKed with some time period, you resend only the messages in that packet that were marked as reliable. If you have time-sensitive messages, you may need something more complex were you resend the message only if a newer message of the same ID/type hasn't replaced it in the outgoing queue already.

Requisite reading: http://gafferongames.com/networking-for-game-programmers/

You might also look into RakNet, ENet, or several other libraries that already implement all these bits.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .