Multiplayer: tank arena
site/media/lessons/multiplayer-tanks.lesson.ts (5 steps) tanks (packages/editor/template/src/examples/tanks/) is a server-authoritative
multiplayer game on Colyseus: your client sends WASD input and renders all tanks (local +
remote) that the server syncs back. Client-driven bot tanks (bots.ts) join as genuine remote
sessions and wander the arena.
Run it
Section titled “Run it”-
Open the tanks scene. Load
examples/scenes/tanks.vscn.json.
The tank arena. -
Enter play mode — the client joins the
tank_room. On play, the client connects to the Colyseus server (net.connect(...)) and joinstank_room.
The client joins the room. -
Drive your tank with WASD. Input maps to a world-XZ move direction + heading and is sent to the server; an angled camera follows your tank.
WASD input is sent to the server. -
Bot tanks sync from the server. The bot clients are real remote sessions; every tank’s state flows through the room and renders via the Callbacks API (
onAdd/onChange).
Remote tanks sync through the server-authoritative room. -
Stop play mode. Press Stop (or
Escape).
How it works
Section titled “How it works”This is the textbook server-authoritative loop: input up (the client sends its movement
intent), state down (the TankRoom owns authoritative tank state and syncs it via
@colyseus/schema). The client subscribes through the Callbacks API
— onAdd to spawn a tank mesh, onChange to move it (reading live schema fields). “Your” tank
and the bots are all just entries in the same synced collection.
Recap
New functionality
- Ran a server-authoritative multiplayer game
- Drove a tank synced through a Colyseus room
- Saw remote tanks update live
New concepts & skills
- Input goes up; authoritative state comes down
- Colyseus rooms own state via @colyseus/schema
- The Callbacks API (onAdd/onChange) renders synced entities
Next lesson → Multiplayer: Colyseus rooms