Skip to content

Multiplayer: shared-physics playground

capstone lesson Advanced ⏱ 20 min vgai 0.1.0

Prerequisites: Manual — Networking · Multiplayer — Colyseus rooms

What you'll learn

  • Run a server-authoritative shared-physics game on a Colyseus room
  • See players and pushable boxes sync from the server, not P2P
  • Understand server-owned object state with the Callbacks API

What you'll build: A shared-physics arena where your avatar and dynamic boxes are simulated on the server and synced to every client.

Walkthrough — Multiplayer: shared-physics playground · generated by site/media/lessons/tierc-mp-batch.lesson.ts (4 steps)

Notblox’s signature is a shared physics world: every player moves a server-owned avatar and pushes dynamic boxes, and every client renders the same synced positions. Object state lives on the server, not peer-to-peer — so two clients never disagree about where a box is. This port keeps that essence with a light 20 Hz server sim (NotbloxRoom) and the Colyseus Callbacks API on the client.

  1. Open the notblox scene. Load examples/scenes/notblox.vscn.json.

    The notblox scene loaded in the editor
    The shared-physics arena, ready to run.
  2. Enter play mode — the client joins the notblox room. The example connects to notblox_room and registers Callbacks (onAdd/onChange/onRemove) for players and boxes.

    Entering play mode, connecting
    The client connects to notblox_room.
  3. Server-authoritative players and boxes sync. The HUD reads room state live — ● online · 4 players · 5 boxes. The capsule avatars and crates are positioned from server state every frame; the server integrates input and box pushes, then broadcasts.

    Players and boxes synced from the server
    Avatars + boxes rendered from synced server state (4 players, 5 boxes).
  4. Stop play mode. Press Stop (or Escape) — the room connection closes.

Recap

New functionality

  • Ran a server-authoritative shared-physics game
  • Saw players and boxes sync from the server (4 players, 5 boxes)

New concepts & skills

  • Object state is server-owned, not P2P — one authority, no disagreement
  • The server ticks at SIM_INTERVAL_MS; clients render synced positions
  • Callbacks (onAdd/onChange/onRemove) drive client rendering from room state

Next lesson → Multiplayer: tank arena