Owner

Items perform various actions:

  • Being grabbed and moved
  • Moving based on physics
  • Trigger gimmicks
  • ClusterScript

All of these are achieved by receiving input from players, processing it accordingly, and displaying the results to all players.

Distributed execution of items

Spaces and items are executed across players' devices and servers. Therefore, at some point, data needs to be sent over the network to another device or server.

For example, consider an item that changes color when clicked:

$.onClick(() => $.material("main").setBaseColor(...));

If Player A interacts with this item, the data flow would look like this:

  • Input: Player A clicks on their device
    • Since it’s unknown who will click, all devices need to listen for the click
    • $.onClick or trigger components run on all devices, converting the device’s click into something usable within the space
  • Processing: The action of changing the color when clicked ($.material("main").setBaseColor(...))
    • This is executed on a single device
  • Display: The item’s color changes are displayed on the screens of all players
    • Actions like setBaseColor change the internal property values of the item
    • These property values are sent over the network via the server to all devices, where each device updates the Unity GameObject properties

Here, the input happens on the operator’s device, the display is shown on all devices, but there are multiple possibilities for where the processing occurs. In Cluster, a single device is generally always responsible for processing, and this is referred to as the owner. In this case, Player A (or Player A’s device) is the owner of this item.

By having the owner handle the processing, even if using physics or random numbers, the results are synchronized correctly across all players without divergence.

Speculative execution

Typically, each item has a single owner at any given time, and only the owner executes processing. However, in cases where the owner changes as players interact with the item, special handling occurs.

When a player interacts with an item, before the ownership is fully transferred, processing is executed on the player’s device as if ownership had already shifted. This is called speculative execution.

In most cases, it’s not a problem to assume that ownership transfers instantly. However, in cases such as when the previous owner disconnects from the network simultaneously, you might see a temporary rollback of the processing.

Ownership of generated items

For world-generated items or dynamically generated craft items, the initial owner is the same as the owner of the item that performed the generation.