Examples

Practical multiplayer state machine examples

Real-world examples of networked state machines.

Networked Door

A door that any player can interact with, synced across all clients:

Trigger: On Interact [Run on Owner]
โ””โ”€ Action: Toggle Door State [RPC to All]
    โ”œโ”€ True โ†’ Action: Open Door Animation [Run on All]
    โ””โ”€ False โ†’ Action: Close Door Animation [Run on All]

How It Works

  1. Only the interacting player's client detects the interaction

  2. The toggle state is sent to all clients via RPC

  3. All clients play the appropriate animation

Synced Health Pickup

A pickup that only the server validates, preventing cheating:

Trigger: On Trigger Enter [Run on Master]
โ””โ”€ Condition: Is Player? [Run on Master]
    โ””โ”€ True โ†’ Actions [RPC to All]:
        โ”œโ”€ Add Health
        โ”œโ”€ Play Sound
        โ””โ”€ Destroy Pickup

How It Works

  1. Only the server checks for collisions

  2. Server validates it's a player

  3. Server sends RPC to give health and destroy pickup

  4. All clients see the same result

Multiplayer Chest

A chest that can only be opened once, with loot visible to all:

How It Works

  1. Any player can interact

  2. Server checks if already opened (prevents race condition)

  3. State change and effects sync to all clients

Player Ability

A player ability with local effects and networked damage:

How It Works

  1. Only the casting player sees their own VFX/sound

  2. Damage is synced to all clients

  3. All clients see the hit effect on the target

Game Manager

A server-authoritative game flow controller:

How It Works

  1. Server controls all game flow decisions

  2. State changes are broadcast to all clients

  3. Clients update their UI based on RPCs received

Last updated

Was this helpful?