When building cross-platform games, the difference between a game that feels "tight" and one that feels "floaty" almost always comes down to custom multiplayer netcode. Off-the-shelf networking solutions are fine for turn-based games, but for real-time action, you need bespoke infrastructure.
Deterministic Lockstep vs. State Sync
There are two primary architectures for real-time multiplayer:
- Deterministic Lockstep: Every client runs the exact same simulation. The server only relays inputs. This requires absolute determinism (floating-point math must match across all CPUs), which is incredibly difficult in a browser environment.
- State Synchronization: The server runs the authoritative simulation and broadcasts the state to clients. Clients predict their own movement and interpolate other entities.
For fast-paced web and cross-platform games, we typically build custom multiplayer netcode based on authoritative state synchronization with client-side prediction. This masks the inherent latency of the internet.
Sub-50ms Transport Layers
Browsers rely on WebSockets or WebRTC for real-time communication. WebSockets are TCP-based, meaning packet loss causes head-of-line blocking (latency spikes).
Our approach utilizes WebRTC data channels configured for unreliable delivery (UDP-like behavior). If a position update packet is dropped, we don't care about retransmitting it; a newer position update will arrive in the next tick anyway. This custom implementation is how we achieve sub-50ms sync even on suboptimal mobile networks.