Skip to main content

Prediction in multiplayer games

In order to avoid network traffic-related lag in the gameplay, prediction is needed. This means running the identical game logic locally and on the server side. This technique allows the players to see results of their actions immediately, without having to wait for a confirmation from the server.

Let's demonstrate this with the following example. The client sends an input, then wants to initiate an animation that lasts 100 ms. Due to the fact that the client has to wait for a response from the server, the whole action takes 200 ms, as for the first 100 ms the client waits for a response.

Without Prediction

No prediction

In order to eliminate the traffic-related lag, we have implemented the prediction mechanism in the Elympics SDK. This allows the game to run locally at the same time as waiting for acknowledgement of inputs from the server.

With Prediction

Prediction

This way we can eliminate any multiplayer-related lag in local player movement, leading to the same response time as you get in a single player game. In our example the whole action takes 100 ms less than without the prediction mechanism.


This, however, can lead to an invalid state locally, which makes it really difficult to debug. Fortunately, Elympics SDK comes with prediction's best friend – reconciliation!