Multiplayer: third-person tag arena
site/media/lessons/tierc-mp-batch.lesson.ts (5 steps) The arena is a full multiplayer game, not just a synced scene: a connect screen, a lobby, a
server-driven match loop, and AI bots β all owned by ArenaRoom. This capstone walks the
connection flow you can capture reliably, then explains the match loop from the server code.
-
Open the arena scene. Load
examples/scenes/arena.vscn.json.
The tag arena, ready to run. -
Enter play mode β the example shows a connect screen. Name, player color, bot count, and the server URL (
ws://127.0.0.1:2567). The menu lives inphase-overlay.tsx.
The connect form: name, color, bot count, server URL. -
Click Join Game β the client joins the arena room.
network.tsopens the room and the UI advances to the lobby phase.
Connected: the lobby reads server state (+ 2 bots) and shows the host's Start Game. -
The lobby reflects server state. The
+ 2 botsline and the Start Game button are driven by the room: bots are server-spawned NPCs, and the button renders only for the host (view.isHost). Pressing it sendsstart_game, moving the room to the countdown.
Server-driven lobby: spawned bots and host-only controls. -
Stop play mode. Press Stop (or
Escape) β the room connection closes.
Recap
New functionality
- Connected to a Colyseus room through a real lobby flow
- Read server-driven lobby state (spawned bots, host controls)
New concepts & skills
- A multiplayer game is a phase machine: lobby β countdown β playing β scoreboard
- start_game is host-gated and phase-gated on the server
- Tagging and AI bots are server-authoritative; clients send input and render state
Next lesson β Multiplayer: tank arena