Ownership
How Ownership and authority works in ObjectNet (Active X Passive)
In ObjectNet, ownership is the cornerstone of how network objects are controlled and synchronized across all clients. Ownership determines which client actively controls an object and how other clients passively interact with it. To provide clarity and ensure smooth gameplay, ObjectNet defines ownership in terms of Active and Passive states.

Active
A client with Active Ownership is responsible for directly controlling the network object. This means:
They dictate the object's behavior (e.g., position, actions, animations).
They send updates to the network so other clients can stay synchronized.
An object in the Active state is fully controlled by its owner, ensuring minimal latency and the most responsive experience for the controlling player.
Example:
Imagine a multiplayer racing game:
Player A owns and drives a car. As the Active Owner, Player A decides the car’s movements (steering, acceleration, braking) and updates the server with the car’s state.
Player A's inputs are sent to the server, which then propagates these updates to other players.
You can check if a NetworkObject
is in the Active State (meaning you own and control the object) by using isActive()
.
Passive
All other clients are in a Passive State for objects they do not own. Clients in this state:
Cannot control the object directly.
Receive updates from the active owner to represent the object accurately on their side.
The passive representation ensures all players can see the object’s latest state (e.g., position, speed, or visual effects) without conflicting with the active owner’s control.
Example:
In the same racing game:
Player B and Player C observe Player A's car as it moves around the track.
Their clients receive updates from Player A, which synchronize the car’s position, speed, and direction. Player B and Player C display these updates without directly modifying the car’s state
To check if a NetworkObject
is in the Passive State (meaning you are not the owner and only receive updates), you can use the isPassive()
Dynamic Ownership Transfer
ObjectNet supports dynamic ownership transfer, which is crucial for flexible gameplay scenarios. Ownership can be reassigned between clients as needed:
Disconnection: If the active owner disconnects, another client automatically takes over to maintain control of the object.
Gameplay Mechanics: Certain scenarios, such as passing a ball in a sports game or handing over an item in a co-op game, may require ownership to be transferred from one client to another dynamically.
To be able to transfere authority the NetworkObject OwnerShip Access Level need to be set to "Full" and OwnerShip working mode to "Use Prefab Definition" or "Allowed".


Code Implementation
You can Take the OwnerShip of a passive NetworkObject using TakeControl()
method, it will change the authority state of the NetworkObject from Passive to Active on the Client that calls it, And set it to Passive on all other clients.
//Takes the authority over the NetworkObject
TakeControl();
//transfere the controls to another player using players Network ID
TransferControl(int playerNetworkID);
//returns the control back to the server
ReleaseControl();
Last updated