You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Documentation~/terms-concepts/ownership.md
+25-6Lines changed: 25 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,11 @@ By default, Netcode for GameObjects assumes a [client-server topology](./client-
6
6
7
7
Netcode for GameObjects also supports building games with a [distributed authority topology](./distributed-authority.md), which provides more options for ownership and authority over NetworkObjects.
8
8
9
-
## Ownership and distributed authority
9
+
## Ownership in client-server
10
+
11
+
In a client-server topology, the server has ultimate authority over all NetworkObjects. Clients can request ownership of [specific objects](../components/core/networkobject.md#ownership), but the server has the final say in whether to grant or deny these requests.
12
+
13
+
## Ownership in distributed authority
10
14
11
15
In a distributed authority setting, authority over NetworkObjects isn't bound to a single server, but distributed across clients depending on a NetworkObject's [ownership permission settings](#ownership-permission-settings-distributed-authority-only). NetworkObjects with the distributable permission set are automatically distributed amongst clients as they connect and disconnect.
12
16
@@ -20,20 +24,35 @@ When another player joins, as in the following diagram, authority over distribut
The following ownership permission settings, defined by `NetworkObject.OwnershipStatus`, only take effect when using a distributed authority network topology:
27
+
The following ownership permission settings, defined by [`NetworkObject.OwnershipStatus`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkObject.OwnershipStatus.html), are only relevant when using a distributed authority network topology:
24
28
25
-
|**Permission setting**|**Description**|
29
+
|**Ownership setting**|**Description**|
26
30
|-------------------|-------------|
27
-
|`None`| Ownership of this NetworkObject is considered static and can't be redistributed, requested, or transferred (a Player might have this, for example). |
31
+
|`None`| Ownership of this NetworkObject can't be redistributed, requested, or transferred (a Player might have this, for example). |
28
32
|`Distributable`| Ownership of this NetworkObject is automatically redistributed when a client joins or leaves, as long as ownership is not locked or a request is pending. |
29
33
|`Transferable`| Ownership of this NetworkObject can be transferred immediately, as long as ownership isn't locked and there are no pending requests. |
30
34
|`RequestRequired`| Ownership of this NetworkObject must be requested before it can be transferred and will always be locked after transfer. |
31
-
|`SessionOwner`| This NetworkObject is always owned by the [session owner](./distributed-authority.md#session-ownership) and can't be transferred or distributed. If the session owner changes, this NetworkObject is automatically transferred to the new session owner. |
35
+
|`SessionOwner`| This NetworkObject is always owned by the [session owner](distributed-authority.md#session-ownership) and can't be transferred or distributed. If the session owner changes, this NetworkObject is automatically transferred to the new session owner. |
32
36
33
37
You can also use `NetworkObject.SetOwnershipLock` to lock and unlock the permission settings of a NetworkObject for a period of time, preventing ownership changes on a temporary basis.
34
38
35
39
> [!NOTE]
36
-
> The ownership permissions are only visible when the Multiplayer Services SDK package is installed and you're inspecting a NetworkObject within the editor. Ownership permissions have no impact when using a client-server network topology, because the server always has authority. For ownership permissions to be used, you must be using a distributed authority network topology.
40
+
> The ownership permissions are only visible when you have the Multiplayer Services SDK package installed and you're inspecting a NetworkObject within the Editor. Ownership permissions have no impact when using a client-server network topology, because the server always has authority.
41
+
42
+
#### Request ownership
43
+
44
+
When requesting ownership of a NetworkObject using [`NetworkObject.RequestOwnership`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkObject.RequestOwnership.html), the following outcomes are possible depending on the ownership status of the NetworkObject when the request is received.
45
+
46
+
|**Ownership status of NetworkObject**|**Response**|**Description**|
|`OwnershipStatus.Transferable`|`OwnershipRequestStatus.RequestSent`| Ownership is transferred immediately, as long as a request isn't already in progress and the NetworkObject's ownership isn't locked. Ownership isn't locked after the transfer. |
49
+
|`OwnershipStatus.RequestRequired`|`OwnershipRequestStatus.RequestSent`| Request granted, as long as a request isn't already in progress and the NetworkObject's ownership isn't locked. Ownership is locked after the request is granted. |
50
+
|`OwnershipStatus.RequestRequired` but `IsOwner` is `true`for the requesting client |`OwnershipRequestStatus.AlreadyOwner`| No action taken. The current client is already the owner. |
51
+
|`OwnershipStatus.RequestRequired` but `IsOwnershipLocked` is `true`|`OwnershipRequestStatus.Locked`| Request denied. The current owner has locked ownership which means requests can't be made at this time. |
52
+
|`OwnershipStatus.RequestRequired` but `IsRequestInProgress` is `true`|`OwnershipRequestStatus.RequestInProgress`| Request denied. A known request is already in progress. You can scan for ownership changes and try again after a specific period of time or no longer attempt to request ownership. |
53
+
|`OwnershipStatus.SessionOwner`|`OwnershipRequestStatus.SessionOwnerOnly`| Request denied. Only the session owner can have ownership of this NetworkObject. |
54
+
|`OwnershipStatus.Distributable`|`OwnershipRequestStatus.RequestRequiredNotSet`| Request denied. Distributable NetworkObjects can only have their ownership changed as part of distribution when clients join or leave a session. |
55
+
|`OwnershipStatus.None`|`OwnershipRequestStatus.RequestRequiredNotSet`| Request denied. Ownership of this NetworkObject can't be redistributed, requested, or transferred. |
0 commit comments