Multiplayer: who decides what happened?
Two pilots, one sky
Kai has an idea: a Hyper Shards co-op mode, where two pilots team up to guard Nova, the space crystal, from the same wave of alien ships.
But each player's laptop runs its own copy of the game. On Kai's screen, alien 7 explodes. On Remy's, alien 7 is still flying. Which screen is right? Every multiplayer game must answer one question: who decides what happened?
Three kinds of multiplayer
- Local (couch) co-opTwo players, one device, two controllers. There is only one copy of the game, so nothing can disagree, and no internet is needed.
- Turn-basedPlayers take turns, so one small database write per move is enough. Firestore handles it well (see Real-time and multiplayer basics).
- Real-time onlineEveryone plays at once, on different devices, many times a second. The hardest kind, and the rest of this lesson.
Multiplayer games come in three main kinds, and the kind decides how much network code you need.
Quick check
Kai wants to try co-op Hyper Shards this weekend, with no servers and no network code at all. Which kind fits?
- Local co-op: two controllers on one laptop
- Real-time online co-op
- Turn-based play through Firestore
Show the answer
Local co-op: two controllers on one laptop
Local co-op runs one copy of the game on one device, so there is nothing to keep in sync. Both online kinds need a server or a database between the players.
Peer-to-peer or client-server?
- Peer-to-peer (P2P)Devices send messages straight to each other. No server to pay for, but every device must trust the others, so one hacked game can lie to everyone. Home routers also often block direct connections.
- Client-serverEvery player talks only to a server. The server keeps the one true copy of the match and tells everyone what happened.
Online games connect players in one of two shapes. The client is the game on each player's device.
The authoritative server
Most online action games use an authoritative server: the server runs the real game, and its word is final. Clients send only their inputs, like "input 412: left and fire". The server applies everyone's inputs, moves every ship and alien, and sends back a snapshot of where everything is now.
The server works in fixed steps called ticks. The tick rate is how many it runs per second. Riot Games runs VALORANT's servers at 128 ticks a second, so each tick must finish in under 7.8 ms.
Spot the cheat
1// messages the server got from clients2{ seq: 412, input: "left" }3{ seq: 413, input: "fire" }4{ seq: 414, hit: "alien7", points: 500 }5{ seq: 415, input: "up+fire" }
Our authoritative server should refuse one of these messages. Which line?
- Line 2
- Line 3
- Line 4
- Line 5
Show the answer
Line 4
Clients may only say which buttons they pressed. Line 4 claims a result, a hit worth 500 points, which only the server may decide. Accepting nothing but inputs blocks a whole family of cheats (more in Stopping cheaters).
Prediction: move now, check later
If Kai's ship waited for the server before moving, every key press would feel late by a full ping: the time for a message to go there and back.
So the game uses client-side prediction. It moves Kai's own ship at once, guessing the server will agree. Each snapshot then says "after input 412, you were here". The game puts the ship there and replays inputs 413, 414 and on, which the server hasn't handled yet. This fix-up is reconciliation. Usually the guess was right. A big miss snaps the ship back: rubber-banding.
Interpolation: smooth other ships
Snapshots arrive in steps, and the network delivers some early and some late. Drawing Remy's ship only when a snapshot lands would make it jump.
So the game keeps the two latest snapshots and slides Remy's ship smoothly between them. This is interpolation. The price: other ships are shown slightly in the past, on purpose.
Your own ship is predicted, a little ahead. Other ships are interpolated, a little behind. Some games add lag compensation: when you fire, the server rewinds time to check what you saw.
Netcode pick
Co-op test: my ship moves a moment after I press a key, and Kai's ship jumps around in little steps.
Which pair of fixes matches Remy's two problems?
- Prediction for Remy's own ship, interpolation for Kai's ship
- Interpolation for Remy's own ship, prediction for Kai's ship
- Save both ships to Firestore 60 times a second
Show the answer
Prediction for Remy's own ship, interpolation for Kai's ship
Prediction moves your own ship instantly, then reconciles with the server. Interpolation slides other ships smoothly between snapshots. Writing positions to a database 60 times a second is slow and costly, and fixes neither.
Lobbies, matchmaking and game servers
- LobbyA waiting room where players gather and press Ready before a match starts.
- MatchmakingThe system that picks who plays together: similar skill, and a server region close to everyone so ping stays low.
- Game serverA program that runs the match from the first tick to the last, with a WebSocket open to every player.
A WebSocket is a two-way connection that stays open (standardised in 2011), so server and client can send messages at any moment. Firestore suits the lobby list and the final results, but it stores data. It doesn't run a match many times a second. Where a game server lives is the topic of Your own servers.
Bolt says: Prediction for you, interpolation for everyone else, and the server has the final word. That's the heart of online action games.
Fact-checked 9 October 2026
- Riot Games: VALORANT's 128-tick servers riotgames.com
- MDN: The WebSocket API developer.mozilla.org
- RFC 6455: The WebSocket Protocol rfc-editor.org
- Cloudflare Durable Objects: WebSockets developers.cloudflare.com