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
This example provides you with the fundamental building blocks for smooth synchronized transitions between two non-rigidbody based objects. This includes transitioning from world to local, local to world, and local to local transform spaces.
4
+
This example provides you with the fundamental building blocks for smooth synchronized transitions between two non-rigidbody based objects. This includes transitioning from world to local, local to world, and local to local transform spaces.
The `CharacterController` component is assigned to the `PlayerNoRigidbody` player prefab. It includes a `MoverScriptNoRigidbody` that handles all of the player's motion and includes some additional "non-rigidbody to non-rigidbody" collision handling logic that is applied when a player bumps into a rotation and/or moving body. The player prefab includes a child "PlayerBallPrime" that rotates around the player in local space (nested `NetworkTransform`), and the "PlayerBallPrime" has 3 children ("PlayerBallChild1-3") that each rotates around a different axis of the "PlayerBallPrime". While the end resulting effect is kind of cool looking, they provide a point of reference as to whether there is any deviation of each child's given axial path relative to each parent level. Additionally, it shows how tick synchronized nested `NetworkTransform` components keep synchronized with their parent and how that persists when the parent is parented or has its parent removed.
8
+
The `CharacterController` component is assigned to the `PlayerNoRigidbody` player prefab. It includes a `MoverScriptNoRigidbody` that handles all of the player's motion and includes some additional "non-rigidbody to non-rigidbody" collision handling logic that is applied when a player bumps into a rotation and/or moving body. The player prefab includes a child "PlayerBallPrime" that rotates around the player in local space (nested NetworkTransform), and the "PlayerBallPrime" has 3 children ("PlayerBallChild1-3") that each rotates around a different axis of the "PlayerBallPrime". While the end resulting effect is kind of cool looking, they provide a point of reference as to whether there is any deviation of each child's given axial path relative to each parent level. Additionally, it shows how tick synchronized nested NetworkTransform components keep synchronized with their parent and how that persists when the parent is parented or has its parent removed.
Copy file name to clipboardExpand all lines: Examples/OverridingScenesAndPrefabs/Readme.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,10 +5,10 @@ _Supports using the client-server and distributed authority network topologies._
5
5
6
6
This example, based on the [Netcode for GameObjects Smooth Transform Space Transitions](https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/tree/example/server-client-unique-scenes-and-prefabs/Examples/CharacterControllerMovingBodies), provides and overview of how to use:
7
7
-[`NetworkPrefabHandler`](https://docs.unity3d.com/Packages/[email protected]/api/Unity.Netcode.NetworkPrefabHandler.html) as a way to dynamically control overriding network prefabs and how they are instantiated.
8
-
- For this example, the prefab handler is overriding the player prefab.
8
+
- For this example, the prefab handler is overriding the player prefab.
9
9
-*You will only see the end result of this portion of the example by running a server instance (i.e. not host) as that will create instances of the ServerPlayer network prefab instead of the ClientPlayer network prefab.*
10
-
-[`NetworkSceneManager.SetClientSynchronizationMode`](https://docs.unity3d.com/Packages/[email protected]/api/Unity.Netcode.NetworkSceneManager.html#Unity_Netcode_NetworkSceneManager_SetClientSynchronizationMode_UnityEngine_SceneManagement_LoadSceneMode_) to change the default client synchronization mode (SingleMode) to an additive client synchronization mode.
11
-
- Additive client synchronization mode will prevent already existing preloaded scenes from being unloaded and will use them, as opposed to reloading the same scene, during a client's initial synchronization.
10
+
-[`NetworkSceneManager.SetClientSynchronizationMode`](https://docs.unity3d.com/Packages/[email protected]/api/Unity.Netcode.NetworkSceneManager.html#Unity_Netcode_NetworkSceneManager_SetClientSynchronizationMode_UnityEngine_SceneManagement_LoadSceneMode_) to change the default client synchronization mode (SingleMode) to an additive client synchronization mode.
11
+
- Additive client synchronization mode will prevent already existing preloaded scenes from being unloaded and will use them, as opposed to reloading the same scene, during a client's initial synchronization.
12
12
-*This is a server-side only setting that gets sent to the clients during the initial synchronization process.*
13
13
-[`NetworkSceneManager.VerifySceneBeforeLoading`](https://docs.unity3d.com/Packages/[email protected]/api/Unity.Netcode.NetworkSceneManager.html#Unity_Netcode_NetworkSceneManager_VerifySceneBeforeLoading) in order to control what scenes the server will include when sending the synchronization message to newly connecting clients.
14
14
@@ -19,14 +19,14 @@ This example uses unity services. Upon loading the project for the first time, y
19
19
## Terminology
20
20
21
21
### Shared Scenes
22
-
These are scenes that will be synchronized between a server or session owner and used when a client runs through the initial synchronization process.
23
-
- You can populate these scenes with in-scene placed or dynamically spawned NetworkObjects.
22
+
These are scenes that will be synchronized between a server or session owner and used when a client runs through the initial synchronization process.
23
+
- You can populate these scenes with in-scene placed or dynamically spawned NetworkObjects.
24
24
- These scenes **must be** within the scenes in build list.
25
25
26
26
### Local Scenes
27
-
These are scenes that are always only local to the application instances (server or client) and will not be synchronized.
28
-
- You should not populate these scenes with NetworkObjects.
29
-
-However, this example includes one of several ways you can associate a `MonoBehaviour` with a `NetworkBehaviour`.
27
+
These are scenes that are always only local to the application instances (server or client) and will not be synchronized.
28
+
- You should not populate these scenes with NetworkObjects.
29
+
-However, this example includes one of several ways you can associate a `MonoBehaviour` with a NetworkBehaviour.
30
30
- These scenes can be dynamically created, included in the scenes in build list, or be an addressable loaded at some point prior to connecting or while connected to a session.
31
31
32
32
## Client Synchronization and Scene Validation
@@ -54,16 +54,16 @@ The first scene loaded. Contains a `NetworkManagerBootstrapper` in-scene placed
Handles the pre-network session menu interface along with connect and disconnect events. Since it is derived from `NetworkManager`, it also defines the network session configuration (i.e. `NetworkConfig`). The `NetworkManagerBootstrapper` in-scene placed `GameObject` gets loaded into the DDOL scene automatically and will persist throughout the application life time. This derived class requires the `SceneBootstrapLoader` component.
57
+
Handles the pre-network session menu interface along with connect and disconnect events. Since it is derived from NetworkManager, it also defines the network session configuration (i.e. `NetworkConfig`). The `NetworkManagerBootstrapper` in-scene placed `GameObject` gets loaded into the DDOL scene automatically and will persist throughout the application life time. This derived class requires the `SceneBootstrapLoader` component.
58
58
59
59
#### Scene Bootstrap Loader (component)
60
60

61
61
62
-
This component handles preloading scenes for both the client(s) and server. Upon being started, the `NetworkManagerBootstrapper` component will invoke `SceneBootstrapLoader.LoadMainMenu` method that kicks off the scene preloading process.
62
+
This component handles preloading scenes for both the client(s) and server. Upon being started, the `NetworkManagerBootstrapper` component will invoke `SceneBootstrapLoader.LoadMainMenu` method that kicks off the scene preloading process.
63
63
-**Default Active Scene Asset:** There is always an active scene. For this example, the default active scene is the same on both the client and server relative properties. *The active scene is always (and should always) be a "shared scene".*
64
64
- This could represent a lobby or network session main menu (i.e. create or join session).
65
65
- Both the client and the server preload this scene prior to starting a network session.
66
-
-**Local Scene Assets:** There could be times where you want to load scenes specific to the `NetworkManager` instance type (i.e. client, host, or server).
66
+
-**Local Scene Assets:** There could be times where you want to load scenes specific to the NetworkManager instance type (i.e. client, host, or server).
67
67
- These scenes are not synchronized by a server (client-server) or session owner (distributed authority).
68
68
- Having different locally loaded scenes is typically more common in a client-server network topology.
69
69
- In a distributed authority network topology, it is more common to keep all scenes synchronized but you might want to load non-synchronized scenes (i.e. menu interface for settings etc).
@@ -72,11 +72,11 @@ This component handles preloading scenes for both the client(s) and server. Upon
72
72
- If the server synchronizes any scenes from the share scene assets with a client that already has those scene loaded, then those locally loaded scenes on the client side will be used during synchronization.
73
73
- Depending upon how many scenes you want to synchronize and/or how large one or more scenes are, preloading scenes can reduce synchronization time for clients.
74
74
The `NetworkManagerBootstrapper` uses the `SceneBootstrapLoader` component to start the creation or joining of a network session. The logical flow looks like:
75
-
-`NetworkManagerBootstrapper` invokes `SceneBootstrapLoader.StartSession` when you click one of the (very simple) main menu buttons and passes in the mode/type of `NetworkManager` to start.
76
-
- Based on the `NetworkManager` type being started, the `SceneBootstrapLoader` will then:
75
+
-`NetworkManagerBootstrapper` invokes `SceneBootstrapLoader.StartSession` when you click one of the (very simple) main menu buttons and passes in the mode/type of NetworkManager to start.
76
+
- Based on the NetworkManager type being started, the `SceneBootstrapLoader` will then:
77
77
- Load the default active scene using the `UnityEngine.SceneManagement.SceneManager`.
78
78
- Load the local scenes using the `UnityEngine.SceneManagement.SceneManager`.
79
-
- Then it will create or join a network session by either starting the `NetworkManager` or connecting to the sesssion via multiplayer services.
79
+
- Then it will create or join a network session by either starting the NetworkManager or connecting to the sesssion via multiplayer services.
80
80
-_Server or Session Owner only:_
81
81
- If any, load the shared (i.e. synchronized) scene assets using the `NetworkSceneManager`
82
82
@@ -87,7 +87,7 @@ This `MonoBehaviour` component implements the `INetworkPrefabInstanceHandler` in
87
87
- Network Prefab: This is the network prefab that you want to override. In this example, it is what is used to spawn a server-side player prefab and is what is defined within the `NetworkManagerBootstrapper` component.
88
88
- Network Prefab Override: This is what is used to spawn a player prefab on the client-side.
89
89
90
-
At runtime the local `NetworkManager` instance is a client/host or server and will spawn either the ClientPlayer or ServerPlayer prefab. The `NetworkPrefabOverrideHandler` does not need to be a `NetworkBehaviour` and sometimes (especially for overriding the player prefab) it is better to register prefab handlers prior to starting the `NetworkManager`.
90
+
At runtime the local NetworkManager instance is a client/host or server and will spawn either the ClientPlayer or ServerPlayer prefab. The `NetworkPrefabOverrideHandler` does not need to be a NetworkBehaviour and sometimes (especially for overriding the player prefab) it is better to register prefab handlers prior to starting the NetworkManager.
91
91
92
92
## Input Controls
93
93
The following is a list of the input controls used in this project:
0 commit comments