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:
| Goal | Example |
|---|---|
| Local network play-testing | Open the game on a laptop and tablet |
| Realtime object sync | Move objects or players in the same room |
| Network events | Broadcast a Flow event to other clients |
| Device testing | Check 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:
| Field | Purpose |
|---|---|
| Player name | Display name for the current client |
| Endpoint | WebSocket room server URL |
| Room code | Room identifier shared by participants |
| Connect / disconnect | Join 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:
player_ready
round_started
coin_claimed
match_finishedDevelopment setup
For local editor work:
npm run devFor the room worker:
npm --prefix workers/opal-room run devFor public deployment, deploy the Cloudflare Worker and paste the worker endpoint into the Share panel.
Testing multiplayer
- Start the editor.
- Start or deploy the room worker.
- Open the editor on two browser windows or devices.
- Enter the same endpoint and room code.
- Join with different player names.
- 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.