netcode
Netcode is the set of software practices and protocols that enable multiplayer games to transmit data, stay synchronized, and feel responsive across a network. It covers state replication, input handling, prediction, reconciliation, and error correction to keep players in a consistent game world despite latency and packet loss.
A common architecture is a client–server model with an authoritative server. Clients send inputs to the server,
- Client-side prediction: projecting local actions forward before server confirmation to feel responsive.
- Server reconciliation: correcting the client state when the server’s authoritative result differs.
- Interpolation: smoothing movement between received state updates to hide jitter.
- Extrapolation: predicting future states when updates lag, which can introduce errors.
- Lag compensation: methods to make actions feel fair despite latency, such as rewinding to the moment
- Rollback netcode: commonly used in fast-paced games (e.g., fighting games), where mispredictions trigger a quick rollback
- Lockstep: used in certain genres (notably some real-time strategy games), requiring determinism and can be sensitive
Important considerations include tick rate and bandwidth, choice of protocol (UDP for real-time, with optional reliability