Client-side prediction
Move instantly, then agree with the server.
If your own character only moves when the server confirms, every keypress waits a full round trip, and with 150 ms ping it feels like walking through mud. Prediction applies your input immediately on your machine, keeps a list of unconfirmed inputs, and when the server answers, replays them from the server's state so you rarely see a correction.
Try this: Move with prediction off at 200 ms ping: the response is sluggish. Turn prediction on (P).
Move left and right.
Prompt bit
Works for 2D or 3D in any engine (Unity, Unreal, Godot, web). Paste the short one for a quick fix, or the detailed one when you want it done properly.
Add client-side prediction: apply local inputs immediately, tag each with a sequence number and keep unacknowledged ones, and when the server state arrives (often 0.1 s later) reset to it and replay newer inputs, smoothing small corrections instead of snapping.
Add client-side prediction with server reconciliation for the local player (2D or 3D, server-authoritative networking; many libraries have helpers, e.g. Netcode for GameObjects client prediction samples, Fish-Net prediction, Photon Fusion). Each tick, sample input, give it a sequence number, apply it to the local player using the same deterministic movement code as the server, send it, and store it in a pending list. When a server state arrives with the last processed sequence number, set the local player to the server state, drop acknowledged inputs, and replay the remaining pending inputs. If the corrected position differs only slightly from what was shown, blend the visual over about 0.1 s; snap if the error is large. Use a fixed tick rate shared with the server. Do not predict things you do not control.
Where it's used
- Online shooters: instant movement and shooting
- Action and fighting games: responsive controls online
- Racing games: your own car
- MMOs: local movement before server confirmation
- Co-op games: playing well on high ping
Common mistakes
Different movement code on client and server so corrections happen constantly, not replaying pending inputs after a correction (rubber-banding), variable timesteps, snapping every tiny correction, and predicting other players instead of interpolating them.
Writing this with an AI assistant? See our best AI coding assistants for game developers.
Missing a concept? Request one.



