๐Ÿค Client-Side Prediction and Server Reconciliation

In multiplayer games, the server is often authoritative โ€” it is the single source of truth for game state. But network latency means players would feel a noticeable delay between pressing a key and seeing the result if they waited for the serverโ€™s response. Client-side prediction and server reconciliation solve this.

Client-Side Prediction

The client doesnโ€™t wait for the server. When a player presses โ€œmove forwardโ€, the client immediately simulates the result locally using the same game logic as the server. The player sees instant feedback. In the background, the input is sent to the server for validation.

Server Reconciliation

When the server processes an input and sends back the authoritative state, the client compares it to its prediction. If they match, nothing happens. If they diverge (because of lag, cheating, or conflicting actions), the client corrects its state to match the serverโ€™s version and replays any inputs that happened since then.

Input Validation

The server must validate every input it receives. Never trust the client โ€” a modified client could send impossible inputs (teleporting, moving too fast, firing without ammo). The server runs its own simulation and rejects invalid actions.

Dead Reckoning

For other playersโ€™ characters (that you donโ€™t control), you donโ€™t have future inputs to predict. Instead, you extrapolate their position based on their last known velocity and direction. This is dead reckoning โ€” it keeps movement looking smooth between network updates, though it can cause snapping when corrections arrive.

Rollback Netcode

In fast-paced games (especially fighting games), rollback netcode takes prediction further. The game predicts the opponentโ€™s inputs, and if the prediction was wrong, it rolls back the game state and resimulates forward with the correct inputs โ€” all within a few frames. This produces much smoother gameplay than waiting for input confirmation.

Resources