Multiplayer Game State Sync (Fortnite/PubG) 00:00:01 Your runner moves before the server replies A player taps forward in an online obstacle race. Waiting for a network round trip before drawing any movement feels sluggish. This illustrative game predicts local movement immediately, while the server remains authoritative about the race. The client labels this input twelve thirty-four. The same movement code as on the server. The input is kept until it is confirmed. One datagram carries inputs twelve thirty-two, twelve thirty-three and twelve thirty-four. The server drops numbers it has seen and refuses impossible ones. All inputs of all players for this step, then movement and collisions. The next snapshot confirms input twelve thirty-four and reports where the runner stands. Number inputs so the server can identify which it has processed. Prediction improves response time. It cannot give a client the final authority to decide whether its runner passed through another player. 00:00:51 One authoritative world, different useful snapshots After a simulation tick, two runners stand on opposite sides of the course. Sending every detail about every object to every player wastes bandwidth. Bound each client's relevant view while retaining a common authoritative state. 100 players, 50 bytes each: 5,000 bytes. The ring keeps one second: 300 KB. For player B, 20 players are near or can be heard. Compared with the tick B acknowledged, about 12 bytes for each moving player. The service sends a client-specific snapshot containing the relevant changes for that recipient under the configured packet budget. B will draw it about 100 ms later, between two snapshots. Choose an acknowledged baseline for a delta snapshot. Include enough sequence information to detect when the baseline is missing. State size, update frequency and what can safely be omitted all belong to the bandwidth calculation. 00:01:43 The predicted runner is five units too far ahead Input twelve thirty-four predicts a move from position one hundred, fifty to one hundred ten, fifty. The server knows that another runner is in the way. Its authoritative position after the same input is one hundred five, fifty. Input twelve thirty-four moves the runner's horizontal position from one hundred to one hundred ten on the local screen. Its vertical position stays at fifty. Another player stands in the way. A stops at (105, 50). After applying input twelve thirty-four, the server reports a horizontal position of one hundred five and a vertical position of fifty. 5 units off. More than 0.1, so this needs a correction. Replay inputs twelve thirty-five, twelve thirty-six and twelve thirty-seven from the corrected position, in sequence. The state is right at once. The drawing follows within 100 ms. Start from the accepted state, drop inputs already acknowledged, then replay the remaining local inputs. The simulation can be corrected immediately while rendering smooths a small visible adjustment. Keep those two clocks separate. 00:02:56 Remote runners are deliberately drawn a little in the past The local player can predict its own controls. Remote runners' future controls are unknown. A short interpolation buffer lets the display blend between two received states instead of jumping each time a packet arrives. So we draw the moment 1,080. 1,066 and 1,100. Compute the display time's fraction through the available interval before interpolating position. Use 1,033 and 1,100: 47 of 67 ms, 0.70 of the way from 20 to 40. Use the neighboring snapshots around the chosen display timestamp and interpolate the fraction between them. One missing snapshot can lengthen the interval. Cap extrapolation when no later observation is available, because a moving drawing is not fresh evidence. 00:03:54 Five percent packet loss is not five percent missing movement An input packet disappears on the last turn. The next packet repeats a small recent input history, while a lost snapshot may be superseded by a newer observation. Which missing information must actually be recovered? The lost datagram carried inputs twelve thirty-two, twelve thirty-three and twelve thirty-four. The next datagram repeats twelve thirty-three and twelve thirty-four and adds twelve thirty-five. An earlier datagram already carried twelve thirty-one and twelve thirty-two. B draws between the one before and the one after. B has not acknowledged the lost one, so the server does not compare with it. Deduplicate input sequence numbers, avoid referencing a delta baseline the client never acknowledged, and reconcile against the server. A responsive race now has immediate local feedback, coherent authoritative outcomes and explicit behavior when individual packets disappear.