Ownership¶
Every replicated object has an owner. Ownership determines which client has authority over an object, its actions and state.
For instance, when an object is moved by its owner, the new position is sent to all the other clients, and they apply the changes to their local replicas.
If you try to change the position of the object on a client that does not own it, it will only change locally for that client, and the next update step will likely overwrite the change.
Transferring Ownership¶
Usually, the owner of the object is the room member who instantiated it,
but sometimes ownership may be transferred between room members.
This can happen if the owner of the object leaves the room
and the object in question has the property ConnectionClosedBehaviour
set to ChangeOwnership
.
This can be useful for AI-controlled characters (NPCs) because this way you can ensure that they will always be present in the room and have someone to control them until the last member leaves.
Checking Ownership and Replication¶
StrixReplicator provides two properties
that give useful information for scripts to handle ownership and replication behavior.
These two properties are also available directly in your script that inherits StrixBehaviour
class.
isLocal |
True if this Replicator is attached to the owner object. |
isSync |
True if the object this Replicator is attached to has one or more replicas. |