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
|**[Authority](terms-concepts/authority.md)**| Multiplayer games are games that are played between many different game instances. Each game instance has their own copy of the game world and behaviors within that game world. To have a shared game experience, each networked object is required to have an **authority**. |
8
+
|**[Ownership](terms-concepts/ownership.md)**| Understand how ownership works in Netcode for GameObjects as a precursor to [authority](terms-concepts/authority.md). |
8
9
|**[Network topologies](network-topologies.md)**| Understand and decide which network topology to use in your project. |
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Documentation~/terms-concepts/authority.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,21 +14,19 @@ Netcode for GameObjects provides two authority models: [server authority](#serve
14
14
15
15
The server authority model has a single game instance that is defined as the server. That game instance is responsible for running the main simulation and managing all aspects of running the networked game. Server authority is the authority model used for [client-server games](client-server.md).
16
16
17
-
The server authority model has the strength of providing a centralized authority to manage any potential game state conflicts. This allows the implementation of systems such as game state rollback and competitive client prediction. However, this can come at the cost of adding latencies, because all state changes must be sent to the server game instance, processed, and then sent out to other game instances.
17
+
The server authority model has the strength of providing a centralized authority to manage any potential game state conflicts. This allows the implementation of systems such as game state rollback and competitive client prediction. However, this can come at the expense of adding latencies, because all state changes must be sent to the server game instance, processed, and then sent out to other game instances.
18
18
19
19
Server authority games can also be resource intensive. The server runs the simulation for the entire game world, and so the server needs to be powerful enough to handle the simulation and networking of all connected game clients. This resource requirement can become expensive.
20
20
21
21
Server authority is primarily used by performance-sensitive games, such as first-person shooters, or competitive games where having a central server authority is necessary to minimize cheating and the effects of bad actors.
22
22
23
23
### Distributed authority
24
24
25
-
The distributed authority model shares authority between game instances. Each game instance is the authority for a subdivision of the networked objects in the game and is responsible for running the simulation for their subdivision of objects. Updates are shared from other game instances for the rest of the simulation.
25
+
The [distributed authority model](distributed-authority.md) shares authority between game instances. Each game instance is the authority for a subdivision of the networked objects in the game and is responsible for running the simulation for their subdivision of objects. Updates are shared from other game instances for the rest of the simulation.
26
26
27
-
The authority of each networked object is responsible for simulating the behavior and managing any aspects of running the networked game that relate to the objects it is the authority of.
27
+
The authority of each networked object is responsible for simulating the behavior and managing any aspects of running the networked game that relate to the objects it's the authority of.
28
28
29
-
Because distributed authority games share the simulation between each connected client, they are less resource intensive. Each machine connected to the game processes a subdivision of the simulation, so no single machine needs to have the capacity to process the entire simulation. This results in a multiplayer game experience that can run on cheaper machines and is less resource intensive.
30
-
31
-
The distributed authority model is the authority model used for [distributed authority games](distributed-authority.md).
29
+
Because distributed authority games share the simulation between each connected client, they're less resource intensive. Each machine connected to the game processes a subdivision of the simulation, so no single machine needs to have the capacity to process the entire simulation. This results in a multiplayer game experience that can run on cheaper machines and is less resource intensive.
32
30
33
31
## Checking for authority
34
32
@@ -58,6 +56,10 @@ public class MonsterAI : NetworkBehaviour
58
56
}
59
57
```
60
58
61
-
Using distributed authority with Netcode for GameObjects requires a shift in the understanding of authority: instead of authority belonging to the server in all cases, it belongs to whichever client instance currently has authority. This necessitates a shift away from using local, non-replicated properties to store pertinent states; instead, [NetworkVariables](networkvariable.md) should be used to keep states synchronized and saved when all clients disconnect from a session or ownership is transferred to another client.
59
+
Using distributed authority with Netcode for GameObjects requires a shift in the understanding of authority: instead of authority belonging to the server in all cases, it belongs to whichever client instance currently has authority. This necessitates a shift away from using local, non-replicated properties to store pertinent states; instead, [NetworkVariables](../basics/networkvariable.md) should be used to keep states synchronized and saved when all clients disconnect from a session or ownership is transferred to another client.
60
+
61
+
Distributed authority supports all built-in NetworkVariable data types. Because there's no concept of an authoritative server in a distributed authority session, all NetworkVariables are automatically configured with owner write and everyone read permissions.
62
+
63
+
## Additional resources
62
64
63
-
Distributed authority supports all built-in NetworkVariable data types. Since there's no concept of an authoritative server in a distributed authority session, all NetworkVariables are automatically configured with owner write and everyone read permissions.
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/Documentation~/terms-concepts/client-server.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,19 @@ Client-server is one possible [network topology](network-topologies.md) you can
4
4
5
5
## Defining client-server
6
6
7
-
The client-server topology is made up of two distinct types of game instances. There is one server game instance, and many client game instances. The server is always the[authority](./authority.md) and is responsible for running the main simulation of the game. The server is responsible for simulating physics, spawning and despawning objects, authorizing client requests along with any other responsibilities. Client game instances can then connect to the server to interact with and respond the the server's game simulation.
7
+
A client-server topology consists of two distinct types of game instances: a single server game instance, and one or more client game instances. The server always has[authority](authority.md) and runs the main simulation of the game, including simulating physics, spawning and despawning objects, and authorizing client requests. Client game instances can then connect to the server to interact with and respond to the server's game simulation.
8
8
9
-
Client-server encompasses a number of potential network arrangements. The most common is a dedicated game server, in which a specialized server manages the game and exists solely for that purpose.
9
+
Client-server encompasses multiple potential network arrangements. The most common is a dedicated game server, in which a specialized server manages the game and exists solely for that purpose.
10
10
11
-
An alternative client-server arrangement is to have a [listen server](../learn/listenserverhostarchitecture.md), in which the game server runs on the same machine as a client. In this arrangement, the server game instance is referred to as a host. A host game instance runs as both a server and a client simultaneously.
11
+
An alternative client-server arrangement is a [listen server](../learn/listenserverhostarchitecture.md), in which the game server runs on the same machine as a client. In this arrangement, the server game instance is referred to as a host. A host game instance runs as both a server and a client simultaneously.
12
12
13
13
## Checking for game instance type
14
14
15
15
### `IsServer`
16
16
17
17
`IsServer` or `!IsServer` is the traditional client-server method of checking whether the current game instance is running as a server instance. This is useful for ensuring that the server instance is the only instance running authoritative game logic, such as spawning objects, processing game rules, and validating client actions.
18
18
19
-
You should use `IsServer` to ensure that only the server executes code that should be authoritative or global. For example, spawning enemies, handling core game logic, or updating shared state should only happen on the server. This prevents clients from making unauthorized changes and helps maintain a consistent game state across all connected players.
19
+
Use `IsServer` to ensure that only the server executes authoritative or global code. For example, spawning enemies, handling core game logic, or updating shared state should only happen on the server. This prevents clients from making unauthorized changes and helps maintain a consistent game state across all connected players.
20
20
21
21
```csharp
22
22
publicclassMonsterAI : NetworkBehaviour
@@ -44,9 +44,9 @@ public class MonsterAI : NetworkBehaviour
44
44
45
45
### `IsHost`
46
46
47
-
The `IsHost` property is used to determine if the current game instance is running as both a server and a client simultaneously—a configuration known as a host. In Unity's Netcode for GameObjects, this is common when using a listen server, where the server and one client share the same process.
47
+
Use the `IsHost` property to determine if the current game instance is running as both a server and a client simultaneously, a configuration known as a host. In Netcode for GameObjects, this is common when using a [listen server](../learn/listenserverhostarchitecture.md), where the server and one client share the same process.
48
48
49
-
`IsHost`could be useful for branching resource heavy logic so that a game running as a listen-server can use code-paths optimized for running on end devices.
49
+
`IsHost`can be useful for branching resource heavy logic so that a game running as a listen-server can use code-paths optimized for running on end devices.
50
50
51
51
```csharp
52
52
publicclassMonsterAI : NetworkBehaviour
@@ -80,7 +80,7 @@ public class MonsterAI : NetworkBehaviour
80
80
81
81
### `IsClient`
82
82
83
-
The `IsClient` property is used to check if the current game instance is running as a client. This is helpful for executing logic that should only run on client machines, such as updating UI elements, handling local input, or playing client-specific effects. Use `IsClient` to ensure that code only runs on the client side, preventing unintended execution on the server or in non-client contexts.
83
+
Use the `IsClient` property to check if the current game instance is running as a client. This is helpful for executing logic that should only run on client machines, such as updating UI elements, handling local input, or playing client-specific effects. Use `IsClient` to ensure that code only runs on the client side, preventing unintended execution on the server or in non-client contexts.
84
84
85
85
`IsClient` will be `true` for host instances as a host game instance is running as both a server and a client simultaneously.
86
86
@@ -111,3 +111,9 @@ public class MonsterAI : NetworkBehaviour
111
111
Dedicated servers are often the most expensive network topology, but also offer the highest performance and can provide additional functionality such as competitive client prediction, rollback, and a centralized authority to manage any potential client conflicts. However, this comes at the cost of added latencies when communicating state changes from one client to another, as all state changes must be sent from client to server, processed, and then sent back out to other clients.
112
112
113
113
Client-server is primarily used by performance-sensitive games, such as first-person shooters, or competitive games where having a central server authority is necessary to minimize cheating and the effects of bad actors.
0 commit comments