The golden rule of multiplayer architecture is absolute: Never Trust the Client. The moment an engine trusts a client when it claims "I shot Player B for 100 damage" or "I teleported to the extraction point", your game becomes an open playground for exploits.
1. Client-Side Prediction with Server Reconciliation
If clients waited for the server to confirm every keystroke before moving, the game would feel unplayable due to latency (ping). The industry solution is Client-Side Prediction:
- Client Step: The player presses W. The client immediately moves the local character forward and assigns a sequence tick number (e.g. Tick #500), saving the input in an unacknowledged history buffer.
- Server Step: The server receives the input for Tick #500, verifies player stamina and terrain boundaries, runs its own simulation, and sends back the authoritative position.
- Reconciliation: If the client position deviates from the server position (e.g. an enemy bumped the player), the client rewinds to the server state and re-simulates all inputs from Tick #500 to the current tick.
[Client Press 'W'] -> [Simulates locally (Tick 500)] -> [Displays instant movement]
|
v (Sends {Tick: 500, Input: Forward})
[Server Validates] -> [Advances headless physics] -> [Broadcasts authoritative state]
|
v (Returns {Tick: 500, Position: (10, 0, 5)})
[Client Compares] -> Deviation < 0.05m ? (Smooth) : (Snaps & reconciles unacknowledged inputs)