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: docs/basics/ownership.md
+1
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@ The following ownership permission settings, defined by `NetworkObject.Ownership
27
27
*`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.
28
28
*`Transferable`: Ownership of this NetworkObject can be transferred immediately, as long as ownership is not locked and there are no pending requests.
29
29
*`RequestRequired`: Ownership of this NetworkObject must be requested before it can be transferred and will always be locked after transfer.
30
+
*`SessionOwner`: This NetworkObject is always owned by the [session owner](../terms-concepts/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.
30
31
31
32
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.
Copy file name to clipboardExpand all lines: docs/basics/scenemanagement/using-networkscenemanager.md
+10-12
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ sidebar_label: Using NetworkSceneManager
7
7
## Netcode for GameObjects Integrated Scene Management
8
8
### The `NetworkSceneManager` Provides You With:
9
9
- An existing framework that supports both the bootstrap and scene transitioning scene management usage patterns.
10
-
- Automated client synchronization that occurs when a client is connected and approved.
10
+
- Automated client synchronization that occurs when a client is connected and approved.
11
11
- All scenes loaded via `NetworkSceneManager` will be synchronized with clients during client synchronization.
12
12
-_Later in this document, you will learn more about using scene validation to control what scenes are synchronized on the client, server, or both side(s)_.
13
13
- All spawned Netcode objects are synchronized with clients during client synchronization.
@@ -57,11 +57,11 @@ In order to load a scene, there are four requirements:
57
57
4. A Scene Event can't already be in progress.
58
58
59
59
#### Basic Scene Loading Example
60
-
Imagine that you have an in-scene placed NetworkObject, let's call it "ProjectSceneManager", that handles your project's scene management using the `NetworkSceneManager` and you wanted your server to load a scene when the ProjectSceneManager is spawned.
60
+
Imagine that you have an in-scene placed NetworkObject, let's call it "ProjectSceneManager", that handles your project's scene management using the `NetworkSceneManager` and you wanted your server to load a scene when the ProjectSceneManager is spawned.
61
61
In its simplest form, it can look something like:
62
62
```csharp
63
63
publicclassProjectSceneManager : NetworkBehaviour
64
-
{
64
+
{
65
65
/// INFO: You can remove the #if UNITY_EDITOR code segment and make SceneName public,
66
66
/// but this code assures if the scene name changes you won't have to remember to
67
67
/// manually update it.
@@ -131,14 +131,14 @@ You can be notified of scene events by registering in one of two ways:
131
131
1. Receive all scene event notification types: `NetworkSceneManager.OnSceneEvent`
132
132
2. Receive only a specific scene event notification type: [`NetworkSceneManager`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkSceneManager.html#events) has one for each [`SceneEventType`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.SceneEventType.html)<br/>
133
133
:::info
134
-
Receiving (via subscribing to the associated event callback) only specific scene event notification types does not change how a server or client receives and processes notifications.
134
+
Receiving (via subscribing to the associated event callback) only specific scene event notification types does not change how a server or client receives and processes notifications.
135
135
:::
136
136
137
137
**Receiving All Scene Event Notifications**
138
-
Typically, this is used on the server side to receive notifications for every scene event notification type for both the server and clients. You can receive all scene event type notifications by subscribing to the `NetworkSceneManager.OnSceneEvent` callback handler.
138
+
Typically, this is used on the server side to receive notifications for every scene event notification type for both the server and clients. You can receive all scene event type notifications by subscribing to the `NetworkSceneManager.OnSceneEvent` callback handler.
139
139
140
140
**Receiving A Specific Scene Event Notification**
141
-
Typically, this is used with clients or components that might only need to be notified of a specific scene event type. There are 9 scene event types and each one has a corresponding "single event type" callback handler in `NetworkSceneManager`.
141
+
Typically, this is used with clients or components that might only need to be notified of a specific scene event type. There are 9 scene event types and each one has a corresponding "single event type" callback handler in `NetworkSceneManager`.
142
142
143
143
**As an example:**
144
144
You might want to register for the `SceneEventType.LoadEventCompleted` scene event type to know, from a client perspective, that the server and all other clients have finished loading a scene. This notification lets you know when you can start performing other netcode related actions on the newly loaded and spawned NetworkObjects.
@@ -173,7 +173,7 @@ Unloading the currently active scene, in Netcode, is commonly referred to as "sc
173
173
:::
174
174
175
175
#### Basic Scene Unloading Example
176
-
Below we are taking the previous scene loading example, the `ProjectSceneManager` class, and modifying it to handle unloading. This includes keeping a reference to the `SceneEvent.Scene` locally in our class because `NetworkSceneManager.Unload` requires the `Scene` to be unloaded.
176
+
Below we are taking the previous scene loading example, the `ProjectSceneManager` class, and modifying it to handle unloading. This includes keeping a reference to the `SceneEvent.Scene` locally in our class because `NetworkSceneManager.Unload` requires the `Scene` to be unloaded.
177
177
178
178
**Below is an example of how to:**
179
179
- Subscribe the server to `NetworkSceneManager.OnSceneEvent` notifications.
@@ -301,7 +301,7 @@ Really, if you take away the debug logging code the major differences are:
301
301
### Scene Validation
302
302
Sometimes you might need to prevent the server or client from loading a scene under certain conditions. Here are a few examples of when you might do this:
303
303
- One or more game states determine if a scene is loaded additively
304
-
- Typically, this is done on the server-side.
304
+
- Typically, this is done on the server-side.
305
305
- The scene is already pre-loaded on the client
306
306
- Typically, this is done on the client-side.
307
307
- Security purposes
@@ -345,7 +345,7 @@ The callback is the first thing invoked on the server-side when invoking the `Ne
345
345
346
346
:::caution
347
347
**Client-Side Scene Validation**<br/>
348
-
This is where you need to be cautious with scene validation, because any scene that you don't validate on the client side should not contain Netcode objects that are considered required dependencies for a connecting client to properly synchronize with the current netcode (game) session state.
348
+
This is where you need to be cautious with scene validation, because any scene that you don't validate on the client side should not contain Netcode objects that are considered required dependencies for a connecting client to properly synchronize with the current netcode (game) session state.
349
349
:::
350
350
351
351
### Dynamically Generated Scenes
@@ -368,7 +368,5 @@ See Also: [Client Synchronization Mode](client-synchronization-mode.md)
368
368
369
369
370
370
### What Next?
371
-
We have covered how to access the `NetworkSceneManager`, how to load and unload a scene, provided a basic overview on scene events and notifications, and even briefly discussed in-scene placed NetworkObjects. You now have the fundamental building-blocks one needs to learn more advanced integrated scene management topics.
371
+
We have covered how to access the `NetworkSceneManager`, how to load and unload a scene, provided a basic overview on scene events and notifications, and even briefly discussed in-scene placed NetworkObjects. You now have the fundamental building-blocks one needs to learn more advanced integrated scene management topics.
372
372
_We recommend proceeding to the next integrated scene management topic, "Client Synchronization Mode", in the link below._
373
-
374
-
<!-- Explore the [Netcode Scene Management Golden Path](link) for step-by-step examples of additive scene loading and management. -->
Copy file name to clipboardExpand all lines: docs/installation/migratingfromUNet.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -343,7 +343,7 @@ In Netcode for GameObjects, RPC function names must end with an `Rpc` suffix.
343
343
344
344
See [Messaging System](../advanced-topics/messaging-system.md) for more information.
345
345
346
-
## Replace `OnServerAddPlayer`
346
+
## Replace `OnServerAddPlayer`
347
347
348
348
Replace `OnServerAddPlayer` with `ConnectionApproval` everywhere in your project.
349
349
@@ -663,7 +663,7 @@ Netcode for GameObjects doesn't provide Network Discovery. The Contributions rep
663
663
664
664
After migrating to the Netcode for GameObjects package, you can review the following for what to do next:
665
665
666
-
*Consider using the [Hello World](../tutorials/helloworld.md) and [Golden Path series](../tutorials/goldenpath_series/gp_intro.md) to learn some basics of Netcode for GameObjects.
666
+
*Follow the [client-server quickstart](../tutorials/get-started-with-ngo.md) to learn some basics of Netcode for GameObjects.
667
667
* Explore the educational samples content for a deeper exploration into Netcode for GameObjects:
Copy file name to clipboardExpand all lines: docs/installation/migratingfrommlapi.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ If this appears when you enter Play Mode or save a scene, close the Unity Editor
148
148
149
149
After migrating to the Netcode for GameObjects package, you can review the following for what to do next:
150
150
151
-
*Consider using the [Hello World](../tutorials/helloworld.md) and [Golden Path series](../tutorials/goldenpath_series/gp_intro.md) to learn some basics of Netcode for GameObjects.
151
+
*Follow the [client-server quickstart](../tutorials/get-started-with-ngo.md) to learn some basics of Netcode for GameObjects.
152
152
* Explore the educational samples content for a deeper exploration into Netcode for GameObjects:
Copy file name to clipboardExpand all lines: docs/learn/listenserverhostarchitecture.md
+2
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,8 @@ Disadvantages:
69
69
70
70
A relay server costs money, and the round trip times for packet exchange may be higher because they have to go through the relay server instead of being sent directly to the other client.
71
71
72
+
Unity provides a relay service. Refer to the [Unity Relay documentation](https://docs.unity.com/ugs/manual/relay/manual/introduction) for more information.
73
+
72
74
### NAT Punch-through
73
75
74
76
Network Address Translation (NAT) punch-through, also known as hole punching, opens a direct connection without port forwarding. When successful, clients are directly connected to each other to exchange packets. However, depending on the NAT types among the clients, NAT punching often fails.
<figcaption>To ensure that several different Network Variables are all synchronized at the same exact time we can use client RPC to join these value changes together.</figcaption>
103
-
</figure>
104
-
105
-
`NetworkVariable`s are great when you only care about the latest value.
106
-
107
-
:::
108
-
109
-
110
84
## Summary
111
85
112
86
`NetworkVariable`s are great for managing state, to make sure everyone has the latest value. Use them when you want to make sure newly connected players get an up to date world state.
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**.
7
+
8
+
The authority of a networked object has the ultimate power to make definitive decisions about that object. Each object must have one and only one authority. The authority has the final control over all state and behavior of that object.
9
+
10
+
The authoritative game instance is the game instance that has authority over a given networked object. This game instance is responsible for simulating networked game behavior. The authority is able to mediate the effects of network lag, and is responsible for reconciling behavior if many players are attempting to simultaneously interact with the same object.
11
+
12
+
## Authority models
13
+
14
+
Netcode for GameObjects provides two authority models: [server authority](#server-authority) and [distributed authority](#distributed-authority).
15
+
16
+
### Server authority
17
+
18
+
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).
19
+
20
+
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.
21
+
22
+
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.
23
+
24
+
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.
25
+
26
+
### Distributed authority
27
+
28
+
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.
29
+
30
+
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.
31
+
32
+
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.
33
+
34
+
The distributed authority model is the authority model used for [distributed authority games](distributed-authority.md).
0 commit comments