Skip to content

Multiplayer and sharing

Opal can run fully offline, but it also includes optional multiplayer rooms. Use rooms when you want live network play, shared testing, or synced object state across devices.

Multiplayer requires a WebSocket room endpoint. The repository includes a Cloudflare Worker in workers/opal-room/.

What multiplayer is for

Use multiplayer for:

GoalExample
Local network play-testingOpen the game on a laptop and tablet
Realtime object syncMove objects or players in the same room
Network eventsBroadcast a Flow event to other clients
Device testingCheck touch and desktop behavior at the same time

Do not use multiplayer just to save files across devices. For that, the dev server and exports are simpler.

Open the Share panel

Use the Share button in the top bar.

Typical fields:

FieldPurpose
Player nameDisplay name for the current client
EndpointWebSocket room server URL
Room codeRoom identifier shared by participants
Connect / disconnectJoin or leave the room

Everyone who connects to the same endpoint and room code participates in the same room.

Object network sync

Objects can opt into network sync where supported by inspector fields and components.

Good sync candidates:

  • Player avatars
  • Shared pickups
  • Simple moving props
  • Multiplayer cursors or markers

Poor sync candidates:

  • Pure background art
  • Editor-only markers
  • High-frequency particle effects
  • Objects that can be recreated locally from a deterministic rule

Keep synced state minimal. Networked games get easier when most effects are local and only important gameplay state is synchronized.

Network events in Flow

Flow graphs can broadcast and react to network events where the node catalog exposes network actions/events.

Use network events for:

  • Player joined
  • Player action
  • Shared button press
  • Round start
  • Game over

Prefer named custom events such as:

text
player_ready
round_started
coin_claimed
match_finished

Development setup

For local editor work:

bash
npm run dev

For the room worker:

bash
npm --prefix workers/opal-room run dev

For public deployment, deploy the Cloudflare Worker and paste the worker endpoint into the Share panel.

Testing multiplayer

  1. Start the editor.
  2. Start or deploy the room worker.
  3. Open the editor on two browser windows or devices.
  4. Enter the same endpoint and room code.
  5. Join with different player names.
  6. Play-test only the smallest interaction first.

Debug one networked action at a time. If everything syncs at once, it is harder to identify the broken piece.

Opal Engine — MIT licensed