Multiplayer Sync

Multiplayer Sync

In a multiplayer setup, most objects need to be synced, meaning their movement, visibility, and appearance should be consistent for all players.

To sync an object, one player needs to make a change and then send that update to the other players. This ensures that the change is applied consistently across all players.

There are two important considerations for syncing objects:

  • Communication Traffic: Sync messages are sent to other players over the internet. As the number of objects that need to be synced increases, so does the communication traffic, which can lower performance.
  • Latency: Sending messages over the internet takes a few milliseconds, causing a potential lag. While the change appears instantly for the player who makes it, there can be a short delay before the other players see the update.

To address these issues, a multiplayer game creator can choose not to sync certain objects and instead allow each player to make the change independently. This approach ensures instant changes for each player but can result in inconsistencies, such as different random colors for each player when the event action is to set a random color.

The processing location aka "which player makes the change" can be configured for each event using this event header icon:

More information around processing location

Multiplayer Sync Options

Multiplayer sync can be configured for the selected object, allowing you to toggle sync for event actions, animations, and physics. By default, only event actions are synced, as syncing animations and physics is more resource-intensive and should only be enabled when necessary.

Sync Event Actions

Sync Event Actions is Enabled (Default)

  • Interaction Events: When an interaction event is triggered by a player, the resulting action is executed and then synced with all other players.

  • System and Custom Events: When a system event (like On Update) occurs, the action result is executed on one player and then synced with the others.

Sync Event Actions is Disabled

  • Interaction Events: The event action is executed only for the player who triggered it, and the result is not synced with others, meaning only the triggering player sees the result.

  • System and Custom Events: These events are triggered and executed independently for each player without syncing.

  • Advantages:

    • Less Communication Traffic: Reduces the amount of data transmitted, improving performance.
  • Disadvantages:

    • Inconsistent Object States: Objects might appear differently to each player due to timing and lag issues.

    • Limited Player Interaction: Actions only affect the player who initiated them, which can be useful for specific scenarios.

Note:

  • Unsynced objects act similar to player HUD objects, so that you can now build one-player-only interaction objects outside of a player HUD.
  • The Sync Event Actions option is taken from the target object of an event action, which might not be the object the event is on.
  • The event action target setting is followed by an icon showing the currently selected sync option as either Sync ON or Sync OFF in multiplayer scenes.
  • The sync option can be overridden there by clicking on the icon and selecting either "Force Sync: ON" or "Force Sync: OFF".

Syncing Examples

  1. Yellow Cube with Event: On Interaction Start, Then Myself: Set Color Red

    • Sync ON: When a player clicks on the cube, it turns red for that player, and this change is synced so all players see the cube as red.

    • Sync OFF: When a player clicks on the cube, it turns red only for that player. Other players continue to see the cube as yellow.

  2. Cube with Event: On Update, Then Myself: Move By 1cm

    • Sync ON: The update event is processed on one player and the resulting position change is synced with all other players.

    • Sync OFF: The update event is processed independently on each player, potentially resulting in different positions for each player.

  3. Cube with Event: On Interaction - Set Color to Red (Sync OFF) and On Interaction - Variable "Counting Clicks" (Sync ON) += 1

    • Color Change: The cube turns red only for the player who clicks on it.

    • Click Count Variable: The variable counts upwards for each click, and this count is synced across all players, showing the total number of clicks from all players.

Sync Animations

  • Enabling this option for animated objects keeps their animations synchronized over time. While this requires more communication between players, it ensures that the object's position is consistent for everyone. By default, this option is turned off to reduce communication traffic. It has been relocated from the Animation Advanced Option.

Example: Animated obstacles that need to hit all players at the same location.

Sync Physics

  • Enabling this option for objects with physics ensures that their position, rotation, and velocity remain consistent across all players. This requires additional communication traffic, so it should only be used when it is crucial for the physics object to be in the same position for everyone.

Example: A soccer ball that must be in the same location for all players simultaneously.