Sending state diffs (deltas) and unreliable connections
- by spaceOwl
We're building a realtime multiplayer game, in which each player is responsible for reporting its state on every iteration of the game loop.
The state updates are broadcasted using unreliable UDP.
To minimize state data sending, we've come up with a system that will send only deltas (whatever state data that was changed).
This method however is flawed, since a lost packet will mean that other players will not receive the delta, making the game behave in an unexpected way.
For example:
Assume that state is comprised of: { positionX, positionY, health }
Frame 1 - positionX changed --> send a packet with positionX only.
Frame 2 - health changed // lost !
Frame 3 - positionY changed --> send a packet with positionY only.
// Other players don't know about health change.
How can one overcome this issue then? sending the entire data is not always feasible.