Skip to content
Documentation

Multiplayer Setup

Configure multiplayer in Game Settings before writing network Logic. Begin with two players in a Messages Only room so you can verify the connection before adding synchronized Objects.

Prerequisites

Use an existing 2D Scene and a saved checkpoint. The editor starts a local relay when you playtest with Server left blank. For two exported browser sessions, run the relay included in the Web Folder export as described below. The web host serves the game files; the relay connects its players.

Choose a Mode

Mode Use and responsibility
Messages Only Rooms and message channels. Your Logic interprets messages and changes gameplay state.
Synced Objects Host-authoritative instance synchronization. Decide which player owns an Object and which changes the host accepts.
Lockstep (Deterministic) Shared input on a fixed simulation tick. Gameplay must produce the same result from the same state and input.

Open Game Settings, choose Multiplayer, and turn on Enable multiplayer. Select Mode, Server (relay URL), and Default room. Check Players per room and Next room when full. Connect automatically and Built-in lobby screen determine how players enter the room.

For the first check, choose Messages Only, set Default room to docs-ping, and keep Show connection status in-game on. Both sessions must use the same game build, relay, and room. Messages Only delivers messages; each receiver’s Logic decides what to do with them.

Run a Local Relay

For a test on your Windows PC:

  1. Enable multiplayer, select Messages Only, and set Server (relay URL) to ws://127.0.0.1:8765. Choose Connect automatically on and Built-in lobby screen off for this controlled check.
  2. Publish a Web Folder from the desktop editor. The exported folder includes server/ when multiplayer is enabled and relay source is available. Inspect its README and server/README.md.
  3. Open PowerShell in the exported folder. With the generated README’s Node.js requirement installed, run:
Terminal window
node server/myth-relay.cjs --host 127.0.0.1 --port 8765 --no-turn
  1. Leave that terminal running. In another terminal, serve the exported Web Folder. Open its HTTP address in two independent browser profiles or browsers.
  2. Check the connection status in both sessions before pressing the test button. Stop the relay with Ctrl+C after testing.

This command listens on this PC. Another device cannot reach your PC through its own 127.0.0.1 address. For devices on the same Wi-Fi, the desktop editor’s Multiplayer panel has Host on This Network. It displays a temporary address that other devices enter in the lobby’s Server box. That relay stops when you close the editor and is not saved as the game’s server.

For a game hosted on HTTPS, deploy the exported relay with TLS or a TLS proxy and use a wss:// URL. Follow server/README.md for that server’s setup. Uploading the web game files alone does not start the relay.

Send and Receive One Value

Declare a Number Project Global named receivedCount, default 0. Prepare one Object named Message Probe, with one placement in the startup Scene. Create a Logic Component named Receive Ping and attach it once to Message Probe.

In Receive Ping, add Message Received from the Multiplayer Event category. Set its Channel filter to ping. Connect Change Variable, then Print Debugger Message, then End:

Action Field values
Change Variable Scope: Global; Variable: receivedCount; Operator: +=; Value: 1
Print Debugger Message Message: Ping: {event.message} from {event.fromPlayer}; Category: Network Check; Type: Log

Add a screen-space Button labeled Send 42. Assign a separate Logic Component named Send Ping to its Button Logic slot. In UI Activated, connect Send Message to End:

Send Message field Value
Channel ping
Value 42
To others
Player Id Leave unassigned; this check addresses the other players

Send Message is under Multiplayer > Messages. Its field reference explains everyone, others, host, and a single player. Message Received supplies event.channel, event.message, and event.fromPlayer; see the Event reference.

Add a screen-space Text Object with the template Received: {$receivedCount}. The live Text guide covers this binding. Published games ignore Print Debugger Message, so the visible counter is the check in the exported sessions.

  1. Save and publish this version. Serve that same export in both sessions and wait for both to connect to docs-ping.
  2. In session A, activate Send 42 once. Session B’s counter should become 1; A stays at 0 because To is others.
  3. Send once from B. A becomes 1; B stays at 1.
  4. Send again from A. B becomes 2. Confirm that each activation adds one received message.
  5. Close B, inspect A’s connection status, then open B again and check rejoining. Its counter starts from the authored default; Messages Only does not restore another session’s private game state.

For a single-session Debug Play check, temporarily choose To everyone. The local receiver should count its own message once. Use Multiplayer Connected for a connection diagnostic. Count attachments and Message Probe placements if one message increments the counter twice.

Synchronization and Timing

Synced Objects uses Updates per second for state delivery. Prediction and fair-hit controls affect local responsiveness and hit evaluation; test with delayed network traffic between independent sessions. Keep playing if the host leaves controls host migration. Disconnect the host during a test and check that your game’s state and custom systems continue correctly.

Lockstep has Simulation ticks per second, Input delay in ticks, and Auto-recover from desync. Use seeded randomness and simulation time for shared decisions. A local browser clock or unsynchronized external response can make peers disagree.

Room passwords control entry; they don’t replace server-side validation of game messages. Peer-to-peer and address-server controls are additional transport paths. Get the relay path working before enabling them.

Expected result: both sessions join the intended room, receive a test message, and agree on the allowed state change. Then disconnect one player and check leaving, host departure, reconnection, room capacity, and the status shown to the remaining player.

Troubleshooting

If neither player connects, check relay URL, server availability, and browser network/Console errors. For secure web pages, use a secure transport supported by the relay. If players enter different rooms, inspect room overflow and exact room names.

If Objects disagree, check ownership, mode, and competing local Logic. If lockstep reports desync, reduce the game to one deterministic change and inspect the first divergent tick. Test the final deployed origin as well as local playtest; export permissions and hosting policy affect connections.

See input, saving, and web publishing for related boundaries.

Myth Engine Documentation