Rollback Overview
AFT uses rollback netcode. Every peer simulates the match locally with the inputs it has and predicts the missing remote inputs (it repeats the last one). When the real input arrives and differs from the prediction, the peer loads the saved state of that frame and re-simulates up to the present in the same tick. Players see their own inputs immediately, whatever the latency.
The AFTRollback module is a clean, Unreal native implementation:
- no global state and no C callbacks:
IAFTRollbackSessionandIAFTRollbackHandler(save, load, advance, events); - explicit little-endian serialization of every message (no packed structs or bitfields, which differ between compilers), validation of every incoming packet (size, type, magic, protocol version, sequence), preallocated buffers (no allocation per frame);
- pluggable transports (
IAFTNetTransport): Unreal sockets (platform UDP, EOS P2P, Steam sockets), in-process loopback, and a conditioner that simulates latency, jitter and packet loss.
Why it works: the deterministic simulation
Rollback needs a simulation that gives exactly the same result for the same inputs on every machine, and that can be saved and restored cheaply. In AFT:
- the whole match state (
FAFTSimState) is a plain struct without padding: saving a frame is onememcpy, the checksum is a CRC of its bytes; - the simulation uses fixed-point integer math only (
FAFTFixed, 1/1000 cm), never reads the world and never touches actors; - the assets are compiled into a read-only database at battle start (
FAFTSimDatabase) with a content hash.
See Writing Deterministic Code before you change the gameplay code.
Net modes
The net mode is part of the match config (FAFTMatchConfig.NetMode, EAFTNetMode):
| Mode | Session | Use |
|---|---|---|
Offline | none | Local play, no rollback. |
SyncTest | sync test session | Every frame is rolled back and re-simulated, checksums compared: non deterministic code is reported on the frame it happens. |
LoopbackRollback | 2 P2P sessions on a virtual network | The full online path on one machine: the second peer runs inside the battle session, with simulated latency / jitter / loss. |
Online | P2P session | Two machines, one local and one remote player. |
Spectator | spectator session | Receives the confirmed inputs of a host. |
The battle session (FAFTBattleSession) hides these modes behind one API: the rest of the game does not care whether the match
is offline or online.
Defaults
| Setting | Value |
|---|---|
| Prediction frames | 8 |
| Frame delay online | 2 (AFT Game > Online > Online Frame Delay, 0 to 8) |
| Disconnect timeout | 5 s |
| Disconnect notification | after 750 ms without packets |
| Desync check | checksum of the confirmed frames every 30 frames |
Frame delay adds a few frames of input delay so that most remote inputs arrive before they are needed: fewer rollbacks, at the cost of a little latency. Time sync slows down the peer that is ahead so that neither side rolls back more than the other.
Safety checks
- Content check: the session refuses a peer with a different protocol version or a different game hash (content hash of the compiled database + match seed). Two players with different fighter data or rules cannot play together.
- Desync detection: peers exchange the checksum of confirmed frames and raise
DesyncDetected; the result reports it (FAFTMatchResult.bDesynced) and the HUD can display it.
Network stats
UAFTBattleSubsystem::GetNetworkStats (FAFTRollbackNetworkStats) and GetLastRollbackFrames give the ping, the rollback length
and the frame advantage, and OnSessionStatusChanged reports the session status (connecting, running, interrupted,
disconnected...). The default battle HUD shows them during online matches.
Next: Testing the Netcode and Online Backends.