From 622f788442492947a8960e03bb41289135d79783 Mon Sep 17 00:00:00 2001 From: Amy Reeve Date: Tue, 8 Jul 2025 17:59:11 +0100 Subject: [PATCH 1/3] Applying docs fixes for patch release --- .../Documentation~/TableOfContents.md | 14 ++ .../Documentation~/advanced-topics/physics.md | 10 +- .../advanced-topics/reconnecting-mid-game.md | 2 - .../Documentation~/basics/networkobject.md | 5 +- .../client-synchronization-mode.md | 6 +- .../components/networkmanager.md | 6 +- .../Documentation~/configure-connections.md | 2 +- .../Documentation~/install.md | 9 +- .../Documentation~/latency-performance.md | 4 +- .../learn/bossroom/bossroom-actions.md | 15 -- .../learn/bossroom/networkobject-parenting.md | 19 -- .../learn/bossroom/networkrigidbody.md | 8 - .../learn/bossroom/spawn-networkobjects.md | 23 --- .../Documentation~/network-components.md | 5 +- .../networkbehaviour-landing.md | 3 +- .../networkvariables-landing.md | 2 +- .../Documentation~/rpc-landing.md | 2 +- .../Documentation~/samples.md | 8 + .../bitesize/bitesize-clientdriven.md | 20 +- .../bitesize/bitesize-dynamicprefabs.md | 19 +- .../bitesize/bitesize-introduction.md | 16 +- .../bitesize/bitesize-invaders.md | 13 +- .../samples/bitesize/bitesize-landing.md | 11 ++ .../bitesize/bitesize-spaceshooter.md | 9 +- .../samples/bitesize/bitesize-usecases.md | 50 +++++ .../bossroom/architecture.md | 76 ++++---- .../samples/bossroom/bossroom-actions.md | 48 +++++ .../samples/bossroom/bossroom-landing.md | 12 ++ .../bossroom/getting-started-boss-room.md | 182 ++++++++---------- .../bossroom/networkobject-parenting.md | 20 ++ .../samples/bossroom/networkrigidbody.md | 9 + .../bossroom/optimizing-bossroom.md | 5 +- .../samples/bossroom/spawn-networkobjects.md | 24 +++ .../Documentation~/tutorials/helloworld.md | 6 +- 34 files changed, 390 insertions(+), 273 deletions(-) delete mode 100644 com.unity.netcode.gameobjects/Documentation~/learn/bossroom/bossroom-actions.md delete mode 100644 com.unity.netcode.gameobjects/Documentation~/learn/bossroom/networkobject-parenting.md delete mode 100644 com.unity.netcode.gameobjects/Documentation~/learn/bossroom/networkrigidbody.md delete mode 100644 com.unity.netcode.gameobjects/Documentation~/learn/bossroom/spawn-networkobjects.md create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples.md rename com.unity.netcode.gameobjects/Documentation~/{learn => samples}/bitesize/bitesize-clientdriven.md (79%) rename com.unity.netcode.gameobjects/Documentation~/{learn => samples}/bitesize/bitesize-dynamicprefabs.md (95%) rename com.unity.netcode.gameobjects/Documentation~/{learn => samples}/bitesize/bitesize-introduction.md (54%) rename com.unity.netcode.gameobjects/Documentation~/{learn => samples}/bitesize/bitesize-invaders.md (94%) create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-landing.md rename com.unity.netcode.gameobjects/Documentation~/{learn => samples}/bitesize/bitesize-spaceshooter.md (90%) create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-usecases.md rename com.unity.netcode.gameobjects/Documentation~/{learn => samples}/bossroom/architecture.md (81%) create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples/bossroom/bossroom-actions.md create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples/bossroom/bossroom-landing.md rename com.unity.netcode.gameobjects/Documentation~/{learn => samples}/bossroom/getting-started-boss-room.md (65%) create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples/bossroom/networkobject-parenting.md create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples/bossroom/networkrigidbody.md rename com.unity.netcode.gameobjects/Documentation~/{learn => samples}/bossroom/optimizing-bossroom.md (98%) create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples/bossroom/spawn-networkobjects.md diff --git a/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md b/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md index f0ada8ef5b..04eb77034e 100644 --- a/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md +++ b/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md @@ -94,3 +94,17 @@ * [Troubleshooting](troubleshooting/troubleshooting.md) * [Error messages](troubleshooting/error-messages.md) * [FAQ](learn/faq.md) +* [Samples](samples.md) + * [Boss Room](samples/bossroom/bossroom-landing.md) + - [Boss Room](samples/bossroom/getting-started-boss-room.md) + - [Boss Room architecture](samples/bossroom/architecture.md) + * [NetworkObject parenting](samples/bossroom/networkobject-parenting.md) + * [Optimizing Boss Room](samples/bossroom/optimizing-bossroom.md) + * [NetworkRigidbody](samples/bossroom/networkrigidbody.md) + * [Spawn NetworkObjects](samples/bossroom/spawn-networkobjects.md) + * [Bitesize samples](samples/bitesize/bitesize-landing.md) + * [Bitesize use cases](samples/bitesize/bitesize-usecases.md) + * [Bitesize introduction](samples/bitesize/bitesize-introduction.md) + * [Bitesize space shooter](samples/bitesize/bitesize-spaceshooter.md) + * [Bitesize client driven](samples/bitesize/bitesize-clientdriven.md) + * [Bitesize dynamic prefabs](samples/bitesize/bitesize-dynamicPrefabs.md) diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/physics.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/physics.md index 9a0aa023a6..72dd8c5d9f 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/physics.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/physics.md @@ -21,7 +21,7 @@ Some collision events aren't fired when using `NetworkRigidbody`. ## NetworkRigidbody and ClientNetworkTransform -You can use NetworkRigidbody with the [`ClientNetworkTransform`](../components/networktransform.md#clientnetworktransform) package sample to allow the owner client of a NetworkObject to move it authoritatively. In this mode, collisions only result in realistic dynamic collisions if the object is colliding with other NetworkObjects (owned by the same client). +You can use NetworkRigidbody with the [`ClientNetworkTransform`](../components/networktransform.md) package sample to allow the owner client of a NetworkObject to move it authoritatively. In this mode, collisions only result in realistic dynamic collisions if the object is colliding with other NetworkObjects (owned by the same client). > [!NOTE] > Add the ClientNetworkTransform component to your GameObject first. Otherwise the NetworkRigidbody automatically adds a regular NetworkTransform. @@ -30,9 +30,7 @@ You can use NetworkRigidbody with the [`ClientNetworkTransform`](../components/n A common issue with physics in multiplayer games is lag and how objects update on basically different timelines. For example, a player would be on a timeline that's offset by the network latency relative to your server's objects. One way to prepare for this is to test your game with artificial lag. You might catch some weird delayed collisions that would otherwise make it into production. -The ClientDriven [bitesize sample](../learn/bitesize/bitesize-clientdriven.md) addresses this by manually adding forces server-side to offer a buffer before an actual collision, but it still feels wobbly at times. However, this isn't really a solution. - -The best way to address the issue of physics latency is to create a custom `NetworkTransform` with a custom physics-based interpolator. You can also use the [Network Simulator tool](../../tools/network-simulator.md) to spot issues with latency. +The best way to address the issue of physics latency is to create a custom `NetworkTransform` with a custom physics-based interpolator. You can also use the [Network Simulator tool](https://docs.unity3d.com/Packages/com.unity.multiplayer.tools@latest?subfolder=/manual/network-simulator) to spot issues with latency. ## Message processing vs. applying changes to state (timing considerations) @@ -53,8 +51,8 @@ From this list of update stages, the `EarlyUpdate` and `FixedUpdate` stages have While `NetworkTransform` offers interpolation as a way to smooth between delta state updates, it doesn't get applied to the authoritative instance. You can use `Rigidbody.interpolation` for your authoritative instance while maintaining a strict server-authoritative motion model. -To have a client control their owned objects, you can use either [RPCs](message-system/rpc.md) or [NetworkVariables](../basics/networkvariables.md) on the client-side. However, this often results in the host-client's updates working as expected, but with slight jitter when a client sends updates. You might be scanning for key or device input during the `Update` to `LateUpdate` stages. Any input from the host player is applied after the `FixedUpdate` stage (i.e. physics simulation for the frame has already run), but input from client players is sent via a message and processed, with a half RTT delay, on the host side (or processed 1 network tick + half RTT if using NetworkVariables). Because of when messages are processed, client input updates run the risk of being processed during the `EarlyUpdate` stage which occurs just before the current frame's `FixedUpdate` stage. +To have a client control their owned objects, you can use either [RPCs](message-system/rpc.md) or [NetworkVariables](../basics/networkvariable.md) on the client-side. However, this often results in the host-client's updates working as expected, but with slight jitter when a client sends updates. You might be scanning for key or device input during the `Update` to `LateUpdate` stages. Any input from the host player is applied after the `FixedUpdate` stage (i.e. physics simulation for the frame has already run), but input from client players is sent via a message and processed, with a half RTT delay, on the host side (or processed 1 network tick + half RTT if using NetworkVariables). Because of when messages are processed, client input updates run the risk of being processed during the `EarlyUpdate` stage which occurs just before the current frame's `FixedUpdate` stage. To avoid this kind of scenario, it's recommended that you apply any changes received via messages to a Rigidbody _after_ the FixedUpdate has run for the current frame. If you [look at how `NetworkTransform` handles its changes to transform state](https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/blob/a2c6f7da5be5af077427eef9c1598fa741585b82/com.unity.netcode.gameobjects/Components/NetworkTransform.cs#L3028), you can see that state updates are applied during the `Update` stage, but are received during the `EarlyUpdate` stage. Following this kind of pattern when synchronizing changes to a Rigidbody via messages will help you to avoid unexpected results in your Netcode for GameObjects project. -The best way to address the issue of physics latency is to create a custom `NetworkTransform` with a custom physics-based interpolator. You can also use the [Network Simulator tool](../../tools/network-simulator.md) to spot issues with latency. +The best way to address the issue of physics latency is to create a custom `NetworkTransform` with a custom physics-based interpolator. You can also use the [Network Simulator tool](https://docs.unity3d.com/Packages/com.unity.multiplayer.tools@latest?subfolder=/manual/network-simulator) to spot issues with latency. diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/reconnecting-mid-game.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/reconnecting-mid-game.md index d5fd534db4..3707c9e59c 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/reconnecting-mid-game.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/reconnecting-mid-game.md @@ -64,7 +64,6 @@ Depending on your game, you might want to add the following features as well: ## Automatic reconnection example -Check out the [Boss Room sample](../learn/bossroom/getting-started-boss-room.md) for an example implementation of automatic reconnection. The entry point for this feature is in [this class](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/ConnectionManagement/ConnectionState/ClientReconnectingState.cs). Boss Room's implementation uses a state inside a state machine that starts a coroutine on entering it ( `ReconnectCoroutine`) that attempts to reconnect a few times sequentially, until it either succeeds, surpasses the defined maximum number of attempts, or is cancelled. (Check out `OnClientConnected`, `OnClientDisconnect`, `OnDisconnectReasonReceived`, and `OnUserRequestedShutdown`.) @@ -72,4 +71,3 @@ The reconnecting state is entered when a client disconnects unexpectedly. (Check > [!NOTE] > This sample connects with [Lobby](https://docs.unity.com/lobby/unity-lobby-service-overview.html) and [Relay](https://docs.unity.com/relay/get-started.html) services, so the client must make sure it has left the lobby before each reconnection try. -> For more information about how Boss Room leverages Lobby and Relay, refer to [Getting Started with Boss Room](../learn/bossroom/getting-started-boss-room.md#register-the-project-with-unity-gaming-services-ugs). diff --git a/com.unity.netcode.gameobjects/Documentation~/basics/networkobject.md b/com.unity.netcode.gameobjects/Documentation~/basics/networkobject.md index b03ae47843..4cbfb18423 100644 --- a/com.unity.netcode.gameobjects/Documentation~/basics/networkobject.md +++ b/com.unity.netcode.gameobjects/Documentation~/basics/networkobject.md @@ -2,7 +2,7 @@ A NetworkObject is a [GameObject](https://docs.unity3d.com/Manual/GameObjects.html) with a NetworkObject component and at least one [NetworkBehaviour](networkbehaviour.md) component, which enables the GameObject to respond to and interact with netcode. NetworkObjects are session-mode agnostic and used in both [client-server](../terms-concepts/client-server.md) and [distributed authority](../terms-concepts/distributed-authority.md) contexts. -Netcode for GameObjects' high level components, [the RPC system](../advanced-topics/messaging-system.md), [object spawning](object-spawning.md), and [`NetworkVariable`](networkvariable.md)s all rely on there being at least two Netcode components added to a GameObject: +Netcode for GameObjects' high level components, [the RPC system](../advanced-topics/messaging-system.md), [object spawning](object-spawning), and [`NetworkVariable`](networkvariable.md)s all rely on there being at least two Netcode components added to a GameObject: 1. NetworkObject 2. [`NetworkBehaviour`](networkbehaviour.md) @@ -96,7 +96,7 @@ There are times when you want to use a NetworkObject for something that doesn't When a GameObject is instantiated, it gets instantiated in the current active scene. However, sometimes you might find that you want to change the currently active scene and would like specific NetworkObject instances to automatically migrate to the newly assigned active scene. While you could keep a list or table of the NetworkObject instances and write the code/logic to migrate them into a newly assigned active scene, this can be time consuming and become complicated depending on project size and complexity. The alternate and recommended way to handle this is by enabling the **Active Scene Synchronization** property of each NetworkObject you want to automatically migrate into any newly assigned scene. This property defaults to disabled. -Refer to the [NetworkSceneManager active scene synchronization](../scenemanagement/using-networkscenemanager#active-scene-synchronization) page for more details. +Refer to the [NetworkSceneManager active scene synchronization](scenemanagement/using-networkscenemanager.md#active-scene-synchronization) page for more details. ## Scene migration synchronization @@ -112,6 +112,5 @@ Scene migration synchronization is enabled by default. For NetworkObjects that d ## Additional resources -- [PlayerObjects and player prefabs](playerobjects.md) - [NetworkBehaviour](networkbehaviour.md) - [NetworkVariable](networkvariable.md) diff --git a/com.unity.netcode.gameobjects/Documentation~/basics/scenemanagement/client-synchronization-mode.md b/com.unity.netcode.gameobjects/Documentation~/basics/scenemanagement/client-synchronization-mode.md index d90570314a..06ab80b38c 100644 --- a/com.unity.netcode.gameobjects/Documentation~/basics/scenemanagement/client-synchronization-mode.md +++ b/com.unity.netcode.gameobjects/Documentation~/basics/scenemanagement/client-synchronization-mode.md @@ -12,7 +12,7 @@ If you are already familiar with Netcode for GameObjects, then this is most like This means any scene that is loaded on the client side prior to being synchronized will be unloaded when the first/default active scene is loaded. -![image](../images/ClientSynchronizationModeSingle.png) +![image](../../images/ClientSynchronizationModeSingle.png) The above image shows a high level overview of single mode client synchronization. For this scenario, a client had just left a network session where the game session was on Level 1. The client still has two common scenes to all levels, Enemy Spawner and World Items scenes, and the Level scenes contain unique assets/settings based on the level number reached. The client then joins a new game session that is on Level 3. With single mode client synchronization, the currently active scene on the server-side is the first scene loaded in `LoadSceneMode.Single` on the client-side (thus why we refer to the client synchronization mode as "single"). By default, loading a new scene in `LoadSceneMode.Single` mode will unload all currently loaded scenes before loading the new scene. Then, for each additional scene that the server requires the client to have loaded in order to be fully synchronized, all remaining scenes are loaded additively (`LoadSceneMode.Additive`). @@ -25,7 +25,7 @@ Additive client synchronization is mode similar to additive scene loading in tha This can be particularly useful if you have common UI element scenes (i.e. menu interfaces) that you would like to persist throughout the duration of the application instance's life cycle (i.e. from the time the application starts to the time it is stopped/exited). It can also be useful to have certain scenes pre-loaded ahead of time to reduce load times when connecting to an existing network session. -![image](../images/ClientSynchronizationModeAdditive.png) +![image](../../images/ClientSynchronizationModeAdditive.png) In the above image we can see a scenario where a server has a Menu UI Scene that it ignores using `NetworkSceneManager.VerifySceneBeforeLoading`, two scenes that the project is configured to always have pre-loaded _(Enemy Spawner and World Items scenes)_, and the server has reached "level 3" of the networked game session so it has the Level 3 scene loaded. The client side almost mirrors the server side (scenes loaded relative) when it began the synchronization process. The only difference between the server and the client was the Level 3 scene that the client has to load in order to be fully synchronized with the server. @@ -39,7 +39,7 @@ When this flag is set on the client side any scenes that were not synchronized w ### NetworkSceneManager.VerifySceneBeforeUnloading When `NetworkSceneManager.PostSynchronizationSceneUnloading` is set to `true` and the client synchronization mode is `LoadSceneMode.Additive`, if this callback is set then for each scene that is about to be unloaded the set callback will be invoked. If it returns `true` the scene will be unloaded and if it returns `false` the scene will remain loaded. This is useful if you have specific scenes you want to persist (menu interfaces etc.) but you also want some of the unused scenes (i.e. not used during synchronization) to be unloaded. -![image](../images/ClientSynchronizationModeAdditive2.png) +![image](../../images/ClientSynchronizationModeAdditive2.png) Let's take the previous client synchronization mode scenario into consideration with the client side having `NetworkSceneManager.PostSynchronizationSceneUnloading` set to `true` and registering a callback for `NetworkSceneManager.VerifySceneBeforeUnloading` where it returns false when client synchronization attempts to unload the Menu UI Scene. Let's also assume this game allows clients to join other network sessions while still in a current network session and that the client had just come from a previous game where the server was still on "level 1" (so the client has the level 1 scene still loaded). When the client begins to synchronize the two pre-loaded scenes are used for synchronization, the client still has to load the Level 3 scene, but at the end of the synchronization `NetworkSceneManager` begins to unload any remaining scenes not synchronized by the server and the client. When the Menu UI Scene is checked if it can be unloaded, the client side `NetworkSceneManager.VerifySceneBeforeUnloading` callback returns `false` so that scene remains loaded. Finally, the Level 1 scene is verified to be unloaded via `NetworkSceneManager.VerifySceneBeforeUnloading` which the user logic determines is "ok" to unload so it returns `true` and the Level 1 scene is unloaded. diff --git a/com.unity.netcode.gameobjects/Documentation~/components/networkmanager.md b/com.unity.netcode.gameobjects/Documentation~/components/networkmanager.md index 33b69d3b23..74e3720b7a 100644 --- a/com.unity.netcode.gameobjects/Documentation~/components/networkmanager.md +++ b/com.unity.netcode.gameobjects/Documentation~/components/networkmanager.md @@ -29,7 +29,7 @@ The `NetworkManager` is a required Netcode for GameObjects component that has al - [NetworkManager.SceneManager](../basics/scenemanagement/using-networkscenemanager.md): When scene management is enabled, this is used to load and unload scenes, register for scene events, and other scene management related actions. - [NetworkManager.SpawnManager](../basics/object-spawning.md): This handles NetworkObject spawn related functionality. - [NetworkManager.NetworkTimeSystem](../advanced-topics/networktime-ticks.md): a synchronized time that can be used to handle issues with latency between a client and the server. -- [NetworkManager.NetworkTickSystem](../advanced-topics/networktime-ticks#network-ticks.md): Use this to adjust the frequency of when NetworkVariables are updated. +- [NetworkManager.NetworkTickSystem](../advanced-topics/networktime-ticks.md#network-ticks): Use this to adjust the frequency of when NetworkVariables are updated. - [NetworkManager.CustomMessagingManager](../advanced-topics/message-system/custom-messages.md): Use this system to create and send custom messages. ## Starting a server, host, or client @@ -47,14 +47,14 @@ NetworkManager.Singleton.StartClient(); // Starts the NetworkManager as jus When starting a Server or joining an already started session as client, the `NetworkManager` can spawn a "Player Object" belonging to the client. For more information about player prefabs, refer to: - - [NetworkObject Player Prefab Documentation](../basics/networkobject.md#player-objects) + - [NetworkObject Player Prefab Documentation](../basics/networkobject.md) - [Connection Approval](../basics/connection-approval) ## Connecting When starting a client, the `NetworkManager` uses the IP and the Port provided in your `Transport` component for connecting. While you can set the IP address in the editor, many times you might want to be able to set the IP address and port during runtime. -The below examples use [Unity Transport](../../../transport/current/about) to show a few ways you can gain access to the `UnityTransport` component via the `NetworkManager.Singleton` to configure your project's network settings programmatically: +The below examples use [Unity Transport](https://docs.unity3d.com/Packages/com.unity.transport@latest?subfolder=/manual/index.html) to show a few ways you can gain access to the `UnityTransport` component via the `NetworkManager.Singleton` to configure your project's network settings programmatically: If you are only setting the IP address and port number, then you can use the `UnityTransport.SetConnectionData` method: ```csharp diff --git a/com.unity.netcode.gameobjects/Documentation~/configure-connections.md b/com.unity.netcode.gameobjects/Documentation~/configure-connections.md index 0071afe73d..ef7c7a4ec4 100644 --- a/com.unity.netcode.gameobjects/Documentation~/configure-connections.md +++ b/com.unity.netcode.gameobjects/Documentation~/configure-connections.md @@ -5,4 +5,4 @@ Configure connections in your project. | **Topic** | **Description** | | :------------------------------ | :------------------------------- | | **[Connection approval](basics/connection-approval.md)** | Connection approval allows you to decide, on a per connection basis, whether to allow a connection. You can also use connection approval to specify the player Prefab to create, allowing you to override the default NetworkManager-defined player Prefab on a per player basis. | -| **[Max players](basics/maxnumberplayers.md)** | Netcode for GameObjects provides a way to customize the [connection approval process](connection-approval.md) that can reject incoming connections based on any number of user-specific reasons. | +| **[Max players](basics/maxnumberplayers.md)** | Netcode for GameObjects provides a way to customize the [connection approval process](basics/connection-approval.md) that can reject incoming connections based on any number of user-specific reasons. | diff --git a/com.unity.netcode.gameobjects/Documentation~/install.md b/com.unity.netcode.gameobjects/Documentation~/install.md index dd2fe5befd..9fb1b54ef6 100644 --- a/com.unity.netcode.gameobjects/Documentation~/install.md +++ b/com.unity.netcode.gameobjects/Documentation~/install.md @@ -29,13 +29,13 @@ Before you begin, you need the following: ## Install Netcode for GameObjects with the Package Manager 1. From the Unity Editor, select **Window** > **Package Manager**. -1. From the Package Manager, select **Add** ![add symbol](../images/add.png) > **Add package by name…** +1. From the Package Manager, select **Add** ![add symbol](images/add.png) > **Add package by name…** 1. Type (or copy and paste) `com.unity.netcode.gameobjects` into the package name field, then select **Add**. ### For Unity Editor versions 2020.3 LTS or earlier 1. From the Unity Editor, select **Window** > **Package Manager**. -1. From the Package Manager, select **Add** ![add symbol](../images/add.png) > **Add package by git URL…** +1. From the Package Manager, select **Add** ![add symbol](images/add.png) > **Add package by git URL…** 1. Type (or copy and paste) `https://github.com/Unity-Technologies/com.unity.netcode.gameobjects` into the git URL field, then select **Add**. ## Next Steps @@ -43,8 +43,3 @@ Before you begin, you need the following: After installing Netcode for GameObjects, see the following content to continue your journey: * Use the [Get started with Netcode for GameObjects tutorial](./tutorials/get-started-with-ngo.md) to create a project, test your installation, and learn how to use the basic features of Netcode for GameObjects. -* Check out the educational samples to further explore Netcode for GameObjects and its abilities: - * [Boss Room](./learn/bossroom/getting-started-boss-room.md) - * [2D Spaceshooter Bitesize sample](./learn/bitesize/bitesize-spaceshooter.md) - * [Invaders Bitesize sample](./learn/bitesize/bitesize-invaders.md) - * [Client-driven Bitesize sample](./learn/bitesize/bitesize-clientdriven.md) diff --git a/com.unity.netcode.gameobjects/Documentation~/latency-performance.md b/com.unity.netcode.gameobjects/Documentation~/latency-performance.md index d378e63b40..26dab6fd56 100644 --- a/com.unity.netcode.gameobjects/Documentation~/latency-performance.md +++ b/com.unity.netcode.gameobjects/Documentation~/latency-performance.md @@ -4,8 +4,8 @@ Manage latency and performance in your Netcode for GameObjects project. | **Topic** | **Description** | | :------------------------------ | :------------------------------- | -| **[Lag and packet loss](learn/lagandpacketloss.md)** | Multiplayer games operating over the internet have to manage adverse network factors that don't affect single-player or LAN-only multiplayer games, most notably [network latency](#network-latency). Latency (also known as lag) is the delay between a user taking an action and seeing the expected result. When latency is too high, a game feels unresponsive and slow. | -| **[Ticks and update rates](learn/ticks-and-update-rates.md)** | In addition to the effects of [latency](lagandpacketloss.md), gameplay experience in a multiplayer game is also affected by the server's [tick rate](#tick-rate) and the client's [update rate](#update-rate). Low tick and update rates reduce game responsiveness and add to perceived latency for users. | +| **[Lag and packet loss](learn/lagandpacketloss.md)** | Multiplayer games operating over the internet have to manage adverse network factors that don't affect single-player or LAN-only multiplayer games, most notably network latency. Latency (also known as lag) is the delay between a user taking an action and seeing the expected result. When latency is too high, a game feels unresponsive and slow. | +| **[Ticks and update rates](learn/ticks-and-update-rates.md)** | In addition to the effects of latency, gameplay experience in a multiplayer game is also affected by the server's tick rate and the client's update rate. Low tick and update rates reduce game responsiveness and add to perceived latency for users. | | **[Client-side interpolation](learn/clientside-interpolation.md)** | You can use client-side interpolation to improve perceived latency for users. | | **[Client anticipation](advanced-topics/client-anticipation.md)** | Netcode for GameObjects doesn't support full client-side prediction and reconciliation, but it does support client anticipation: a simplified model that lacks the full rollback-and-replay prediction loop, but still provides a mechanism for anticipating the server result of an action and then correcting if you anticipated incorrectly. | | **[Dealing with latency](learn/dealing-with-latency.md)** | Understand the available methods for dealing with different kinds of latency. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/bossroom-actions.md b/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/bossroom-actions.md deleted file mode 100644 index edf7ece61c..0000000000 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/bossroom-actions.md +++ /dev/null @@ -1,15 +0,0 @@ -# Boss Room actions walkthrough - -Boss Room's actions each use a different pattern for good multiplayer quality. This doc walks you through each of them and goes into details about how we implemented each and what lessons you can learn from each. You can get their implementations [here](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/tree/v2.1.0/Assets/Scripts/Gameplay/Action). - -![Playing an anticipatory animation on the owner client to appear reactive and hide Network Latency.](../../../images/sequence_diagrams/BossRoomExamples/HidingLatency_AnimationAnticipation.png) - -![Boss Room's mage's bolt doesn't use NetworkVariables and NetworkObjects to track the bolt's state. Since its movement is fast, we only send an RPC to trigger VFX on clients. No need to waste CPU and bandwidth on a NetworkObject over time for this. Even if the FX passes through a wall on some clients (due to network discrepancies in target positions), the FX is so quick it wouldn't be visible to players.](../../../images/sequence_diagrams/BossRoomExamples/RPCFlowExample_MageMagicBolt.png) - -![Boss Room's archer's arrows use fully replicated NetworkObjects + NetworkTransform. Since they're slow moving, we want them to be seen by late joining players. We also want to make sure their behaviour is the same for all clients (so they don't go through walls for example). This will use more bandwidth, but will be more accurate.](../../../images/sequence_diagrams/BossRoomExamples/RPCFlowExample_ArcherRangedShot.png) - -![The archer's volley takes multiple steps. First on click, the client will show a circle VFX tracking the mouse. That FX isn't networked and client side only. Then on click, the client will send an RPC to the server. The server will then apply it's gameplay logic, update the imp's health (tracked by NetworkVariables) and trigger a Client RPC to play the volley animation on all clients.](../../../images/sequence_diagrams/BossRoomExamples/RPCFlowExample_ArcherVolley.png) - -![Emotes only use RPCs. We don't care if a late joining player doesn't see other player's emotes.](../../../images/sequence_diagrams/BossRoomExamples/RPCFlowExample_PlayerEmote.png) - -![Most of the rogue sneak's logic happens server side. Since Boss Room is a coop game, we're not using Network invisibility here, only client side effects. Clients will still receive that invisible player's information and imp AIs will ignore invisible players.](../../../images/sequence_diagrams/BossRoomExamples/RPCFlowExample_RogueSneak.png) diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/networkobject-parenting.md b/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/networkobject-parenting.md deleted file mode 100644 index 4c866c0f11..0000000000 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/networkobject-parenting.md +++ /dev/null @@ -1,19 +0,0 @@ -# NetworkObject parenting inside Boss Room - -> [!NOTE] -> Refer to [NetworkObject Parenting](../../advanced-topics/networkobject-parenting.md) for more information. - -Before detailing Boss Room's approach to `NetworkObject` parenting, it's important to highlight a limitation of Netcode: A dynamically-spawned `NetworkObject` **can't** contain another `NetworkObject` in its hierarchy. If you spawn such a `NetworkObject`, you can't spawn children `NetworkObjects`. You can only add children `NetworkObject` components to a `NetworkObject` that is part of a scene. - -Boss Room leverages `NetworkObject` parenting through the server-driven `PickUp` action (see [`PickUpAction.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/PickUpAction.cs)), where a character has the ability to pick up a specially-tagged, in-scene placed `NetworkObject` (see [`PickUpPot` prefab](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Prefabs/Game/PickUpPot.prefab)]. - -At its root, `PickUpPot` has a `NetworkObject`, a `NetworkTransform`, and a `PositionConstraint` component. `AutoObjectParentSync` is enabled on its `NetworkTransform` (as is by default) so that: - -1. The `NetworkObject` can verify server-side if parenting a Heavy object to another `NetworkObject` is allowed. -2. The `NetworkObject` can notify us when the parent has successfully been modified server-side. - -To accommodate the limitation highlighted at the beginning of this document, Boss Room leverages the `PositionConstraint` component to simulate an object following a character's position. - -A special hand bone has been added to our Character's avatar. Upon a character's successful parenting attempt, this special bone is set as the `PickUpPot`'s `PositonConstraint` target. So while the `PickUpPot` is technically parented to a player, the `PositionConstraint` component allows the `PickUpPot` to follow a bone's position, presenting the **illusion** that the `PickUpPot` is parented to the player's hand bone itself. - -Once the `PickUpPot` is parented, local space simulation is enabled on its [`NetworkTransform` component](../../components/networktransform.md). diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/networkrigidbody.md b/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/networkrigidbody.md deleted file mode 100644 index f539665d67..0000000000 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/networkrigidbody.md +++ /dev/null @@ -1,8 +0,0 @@ -# NetworkRigidbody inside Boss Room - -> [!NOTE] -> Refer to [Physics](../..//advanced-topics/physics.md) for more information. - -Boss Room leverages `NetworkRigidbody` to simulate physics-based projectiles. See the Vandal Imp's tossed projectile, the [`ImpTossedItem` prefab](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Prefabs/Game/ImpTossedItem.prefab). At its root, this Prefab has a `NetworkObject`, a `NetworkTransform`, a `Rigidbody`, and a `NetworkRigidbody` component. Refer to [`TossAction.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/TossAction.cs) for more implementation details. - -An important note: You must do any modifications to a `Rigidbody` that involve Physics (modifying velocity, applying forces, applying torque, and the like) **after** the `NetworkObject` spawns since `NetworkRigidbody` forces the `Rigidbody`'s `isKinematic` flag to be true on `Awake()`. Once spawned, this flag is modified depending on the ownership status of the `NetworkObject`. diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/spawn-networkobjects.md b/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/spawn-networkobjects.md deleted file mode 100644 index d32b577f0b..0000000000 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/spawn-networkobjects.md +++ /dev/null @@ -1,23 +0,0 @@ -# Dynamically spawning NetworkObjects in Boss Room to resolve zombie NetworkObjects - -> [!NOTE] -> Refer to [Object Spawning](../../basics/object-spawning.md) for more information. - -This document serves as a walkthrough of Boss Room's approach to solving the following issue: Late-joining clients entering networked sessions encountering zombie `NetworkObjects`. Zombie `NetworkObjects` represent `NetworkObjects` that are instantiated for a client due to scene loads but aren't despawned or destroyed by Netcode. - -This is a particular Netcode limitation of `NetworkObject` spawning: `NetworkObjects` that belong to a scene object should not be destroyed until its scene has been unloaded through Netcode's scene management. - -The scenario in question: - -* A host loads a scene and destroys a `NetworkObject` that belonged to that scene. -* A client joins the host's session and loads the additive scene. This operation loads **all** the `GameObjects` included in the additive scene. The `NetworkObject` that was destroyed on the server won't be destroyed on the client's machine. - -This scenario manifested inside Boss Room, whereby late-joining clients joining a game session encountered zombie `NetworkObject`s that were not destroyed over the network. - -Additive scenes now contain Prefab instances of a custom spawner, [`NetworkObjectSpawner`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs) to accommodate this visual inconsistency. - -Compositionally, these additive scenes now only contain the following: - -* Prefab instances of level geometry. -* Prefab instances of `NetworkObject`s that will **not** be despawned nor destroyed for the scene's lifetime. Examples include [BreakablePot](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Prefabs/Game/BreakablePot.prefab) and [BreakableCrystal](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Prefabs/Game/BreakableCrystal.prefab). -* Prefab instances of `NetworkObjectSpawner`, which spawn `NetworkObject`s that **may** be destroyed or despawned during the scene's lifetime. Examples include [Imp](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/GameData/Character/Imp/Imp.asset), [VandalImp](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/GameData/Character/VandalImp/VandalImp.asset), and [ImpBoss](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/GameData/Character/ImpBoss/ImpBoss.asset). diff --git a/com.unity.netcode.gameobjects/Documentation~/network-components.md b/com.unity.netcode.gameobjects/Documentation~/network-components.md index 98c90a92ec..272f6ea8b3 100644 --- a/com.unity.netcode.gameobjects/Documentation~/network-components.md +++ b/com.unity.netcode.gameobjects/Documentation~/network-components.md @@ -4,11 +4,10 @@ Understand the network components involved in a Netcode for GameObjects project. | **Topic** | **Description** | | :------------------------------ | :------------------------------- | -| **[NetworkObject](basics/networkobject.md)** | A NetworkObject is a [GameObject](https://docs.unity3d.com/Manual/GameObjects.html) with a NetworkObject component and at least one [NetworkBehaviour](networkbehaviour.md) component, which enables the GameObject to respond to and interact with netcode. | -| **[PlayerObjects and player prefabs](basics/playerobjects.md)** | PlayerObjects are an optional feature in Netcode for GameObjects that you can use to assign a [NetworkObject](networkobject.md) to a specific client. A client can only have one PlayerObject. | +| **[NetworkObject](basics/networkobject.md)** | A NetworkObject is a [GameObject](https://docs.unity3d.com/Manual/GameObjects.html) with a NetworkObject component and at least one [NetworkBehaviour](basics/networkbehaviour.md) component, which enables the GameObject to respond to and interact with netcode. | | **[NetworkObject parenting](advanced-topics/networkobject-parenting.md)** | Understand how NetworkObjects are parented in Netcode for GameObjects. | | **[NetworkBehaviour](networkbehaviour-landing.md)**| Understand how to use NetworkBehaviour components in your Netcode for GameObjects project. | | **[Physics](advanced-topics/physics.md)**| Netcode for GameObjects has a built in approach which allows for server-authoritative physics where the physics simulation only runs on the server. | | **[NetworkManager](components/networkmanager.md)**| The `NetworkManager` is a required Netcode for GameObjects component that has all of your project's netcode-related settings. Think of it as the central netcode hub for your netcode-enabled project. | -| **[NetworkTransform](components/networktransform.md)**| [NetworkTransform](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.Components.NetworkTransform.html) is a concrete class that inherits from [NetworkBehaviour](../basics/networkbehaviour.md) and synchronizes [Transform](https://docs.unity3d.com/Manual/class-Transform.html) properties across the network, ensuring that the position, rotation, and scale of a [GameObject](https://docs.unity3d.com/Manual/working-with-gameobjects.html) are replicated to other clients. | +| **[NetworkTransform](components/networktransform.md)**| [NetworkTransform](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.Components.NetworkTransform.html) is a concrete class that inherits from [NetworkBehaviour](basics/networkbehaviour.md) and synchronizes [Transform](https://docs.unity3d.com/Manual/class-Transform.html) properties across the network, ensuring that the position, rotation, and scale of a [GameObject](https://docs.unity3d.com/Manual/working-with-gameobjects.html) are replicated to other clients. | | **[NetworkAnimator](components/networkanimator.md)**| The `NetworkAnimator` component provides you with a fundamental example of how to synchronize animations during a network session. Animation states are synchronized with players joining an existing network session and any client already connected before the animation state changing. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/networkbehaviour-landing.md b/com.unity.netcode.gameobjects/Documentation~/networkbehaviour-landing.md index 6821d75fbd..bf8981fa11 100644 --- a/com.unity.netcode.gameobjects/Documentation~/networkbehaviour-landing.md +++ b/com.unity.netcode.gameobjects/Documentation~/networkbehaviour-landing.md @@ -4,6 +4,5 @@ Understand how to use NetworkBehaviour components in your project. | **Topic** | **Description** | | :------------------------------ | :------------------------------- | -| **[NetworkBehaviour](basics/networkbehaviour.md)** | [`NetworkBehaviour`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkBehaviour.html) is an abstract class that derives from [`MonoBehaviour`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.html) and is primarily used to create unique netcode or game logic. To replicate any netcode-aware properties or send and receive RPCs, a [GameObject](https://docs.unity3d.com/Manual/GameObjects.html) must have a [NetworkObject](networkobject.md) component and at least one `NetworkBehaviour` component. - | +| **[NetworkBehaviour](basics/networkbehaviour.md)** | [`NetworkBehaviour`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkBehaviour.html) is an abstract class that derives from [`MonoBehaviour`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.html) and is primarily used to create unique netcode or game logic. To replicate any netcode-aware properties or send and receive RPCs, a [GameObject](https://docs.unity3d.com/Manual/GameObjects.html) must have a [NetworkObject](basics/networkobject.md) component and at least one `NetworkBehaviour` component. | | **[Synchronize](basics/networkbehaviour-synchronize.md)** | You can use NetworkBehaviours to synchronize settings before, during, and after spawning NetworkObjects. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/networkvariables-landing.md b/com.unity.netcode.gameobjects/Documentation~/networkvariables-landing.md index 12e51a3f10..b7a5d0abba 100644 --- a/com.unity.netcode.gameobjects/Documentation~/networkvariables-landing.md +++ b/com.unity.netcode.gameobjects/Documentation~/networkvariables-landing.md @@ -5,4 +5,4 @@ Manage latency and performance in your Netcode for GameObjects project. | **Topic** | **Description** | | :------------------------------ | :------------------------------- | | **[NetworkVariable](basics/networkvariable.md)** | Use NetworkVariables to synchronize properties between servers and clients in a persistent manner. | -| **[Custom NetworkVariables](basics/custom-networkvariables.md)** | In addition to the standard [`NetworkVariable`s](networkvariable.md) available in Netcode for GameObjects, you can also create custom `NetworkVariable`s for advanced implementations. | \ No newline at end of file +| **[Custom NetworkVariables](basics/custom-networkvariables.md)** | In addition to the standard [`NetworkVariable`s](basics/networkvariable.md) available in Netcode for GameObjects, you can also create custom `NetworkVariable`s for advanced implementations. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/rpc-landing.md b/com.unity.netcode.gameobjects/Documentation~/rpc-landing.md index d2da74114b..3fda381291 100644 --- a/com.unity.netcode.gameobjects/Documentation~/rpc-landing.md +++ b/com.unity.netcode.gameobjects/Documentation~/rpc-landing.md @@ -4,7 +4,7 @@ Manage latency and performance in your Netcode for GameObjects project. | **Topic** | **Description** | | :------------------------------ | :------------------------------- | -| **[Messaging system](advanced-topics/messaging-system.md)** | Netcode for GameObjects has two parts to its messaging system: [remote procedure calls (RPCs)](message-system/rpc.md) and [custom messages](message-system/custom-messages.md). Both types have sub-types that change their behavior, functionality, and performance. | +| **[Messaging system](advanced-topics/messaging-system.md)** | Netcode for GameObjects has two parts to its messaging system: [remote procedure calls (RPCs)](advanced-topics/message-system/rpc.md) and [custom messages](advanced-topics/message-system/custom-messages.md). Both types have sub-types that change their behavior, functionality, and performance. | | **[RPC](advanced-topics/message-system/rpc.md)** | Any process can communicate with any other process by sending a remote procedure call (RPC). | | **[Reliability](advanced-topics/message-system/reliability.md)** | RPCs are reliable by default. This means they're guaranteed to be received and executed on the remote side. However, sometimes developers might want to opt-out reliability, which is often the case for non-critical events such as particle effects and sound effects. | | **[RPC params](advanced-topics/message-system/rpc-params.md)** | Understand how to configure your RPCs. | diff --git a/com.unity.netcode.gameobjects/Documentation~/samples.md b/com.unity.netcode.gameobjects/Documentation~/samples.md new file mode 100644 index 0000000000..b6a91e5e7d --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples.md @@ -0,0 +1,8 @@ +# Samples + +Use the samples in this section to learn how to use Netcode for GameObjects in your projects. The samples are designed to help you understand the concepts and features of Netcode for GameObjects, and they provide practical examples of how to implement multiplayer functionality in Unity games. + +| **Topic** | **Description** | +| :------------------------------ | :------------------------------- | +| **[NetworkBehaviour](basics/networkbehaviour.md)** | [`NetworkBehaviour`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@latest?subfolder=/api/Unity.Netcode.NetworkBehaviour.html) is an abstract class that derives from [`MonoBehaviour`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.html) and is primarily used to create unique netcode or game logic. To replicate any netcode-aware properties or send and receive RPCs, a [GameObject](https://docs.unity3d.com/Manual/GameObjects.html) must have a [NetworkObject](basics/networkobject.md) component and at least one `NetworkBehaviour` component. | +| **[Synchronize](basics/networkbehaviour-synchronize.md)** | You can use NetworkBehaviours to synchronize settings before, during, and after spawning NetworkObjects. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-clientdriven.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-clientdriven.md similarity index 79% rename from com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-clientdriven.md rename to com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-clientdriven.md index 3759e999fa..f31a3dc137 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-clientdriven.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-clientdriven.md @@ -1,26 +1,28 @@ # ClientDriven sample -## Client Driven Movements +## Client-driven movements + Making movements feel responsive while staying consistent over multiple game executables, each with their own timelines, is a challenge for many networked games. ## TLDR: -- Use [ClientNetworkTransform](../../components/networktransform.md#clientnetworktransform) to sync client authoritative transform updates to the server and other clients. +- Use [ClientNetworkTransform](../../components/networktransform.md) to sync client authoritative transform updates to the server and other clients. - Make sure ownership is set properly on that NetworkObject to be able to move it. - Since your clients live on different timelines (one per player), you have to be careful about who takes decisions and keep some of those decisions centralized on the server. - DON'T FORGET to test with latency, as your game will behave differently depending on whether client or server make decisions. -## Sample: +## Sample ClientDriven's aim is to create a quick sample to show responsive character movements that don't feel sluggish, even under bad network conditions. -It uses the ClientNetworkTransform component and moves your own player's position client side, [client authoritatively](../dealing-with-latency.md#allow-low-impact-client-authority). Movement is leveraged through the use of Unity's Starter Assets, the [Third Person Character Controller](https://assetstore.unity.com/packages/essentials/starter-assets-third-person-character-controller-196526). +It uses the ClientNetworkTransform component and moves your own player's position client side, [client authoritatively](../../learn/dealing-with-latency.md#allow-low-impact-client-authority). Movement is leveraged through the use of Unity's Starter Assets, the [Third Person Character Controller](https://assetstore.unity.com/packages/essentials/starter-assets-third-person-character-controller-196526). ```csharp reference https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/v1.2.1/Basic/ClientDriven/Assets/StarterAssets/ThirdPersonController/Scripts/ThirdPersonController.cs#L155-L162 ``` -### Client side object detection for pickup with server side pickup validation -Ingredients in ClientDriven are owned by the server, since they're [shared objects](../dealing-with-latency.md#issue-world-consistency). This means if a player tries to grab an object while that object is moving, a server side range detection would sometimes fail, even though it should have succeeded (since ingredients are replicated with some lag, so the player would try to grab ingredients that are a few milliseconds behind). +### Client-side object detection for pickup with server side pickup validation + +Ingredients in ClientDriven are owned by the server, since they're [shared objects](../../learn/dealing-with-latency.md#issue-world-consistency). This means if a player tries to grab an object while that object is moving, a server side range detection would sometimes fail, even though it should have succeeded (since ingredients are replicated with some lag, so the player would try to grab ingredients that are a few milliseconds behind). To make sure this doesn't happen, the object detection done to grab an ingredient is also done client side. ```csharp reference @@ -40,7 +42,8 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blo ``` If the object is already picked up, we're not doing anything. Your client side animations should take this into account and cancel any animations "carrying" something. -### Server side player spawn points +### Server-side player spawn points + In this sample, our spawn points list is server side (to have a single source of truth). ClientNetworkTransforms can be updated by owners only, which means the server can't update the player's position directly. This means OnNetworkSpawn, the server will need to assign a position to the player using a ClientRPC. @@ -49,7 +52,8 @@ This means OnNetworkSpawn, the server will need to assign a position to the play https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/v1.2.1/Basic/ClientDriven/Assets/Scripts/ServerPlayerMove.cs#L24-L44 ``` -## Server physics with client driven movements (interactions on different timelines) +## Server physics with client-driven movements (interactions on different timelines) + All the ingredients can be bumped against by players. However, since ingredients are server driven, bumping against them with client driven movements can cause desync issues. This sample uses NetworkRigidbody for ingredients, which sets Kinematic = true, making them immovable client side. This way, only server side movements (from the replicated player movements) will move the ingredients. Two players bumping the same ingredient will still only have one single result, calculated server side, with no risk of desync. diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-dynamicprefabs.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-dynamicprefabs.md similarity index 95% rename from com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-dynamicprefabs.md rename to com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-dynamicprefabs.md index ee40367308..8061b80c2e 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-dynamicprefabs.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-dynamicprefabs.md @@ -1,6 +1,6 @@ # Dynamic Prefabs sample -## Dynamic Addressables Network Prefabs Sample +# Dynamic addressables Network Prefabs sample The [DynamicAddressablesNetworkPrefabs Sample](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/tree/main/Basic/DynamicAddressablesNetworkPrefabs) showcases the available ways you can use dynamic Prefabs to dynamically load network Prefabs at runtime, either pre-connection or post-connection. Doing so allows you to add new spawnable NetworkObject Prefabs to Netcode for GameObjects. @@ -14,10 +14,11 @@ This sample covers a variety of possible ways you can use dynamically loaded net There's also the **APIPlayground**, which serves as an API playground that implements all post-connection uses together. -> [!NOTE] -> This sample leverages [Addressables](https://docs.unity3d.com/Packages/com.unity.addressables@1.21/manual/index.html) to load dynamic Prefabs. +:::note +**Note**: This sample leverages [Addressables](https://docs.unity3d.com/Packages/com.unity.addressables@1.21/manual/index.html) to load dynamic Prefabs. +::: -### Scene 00_Preloading Dynamic Prefabs +### Scene 00_Preloading dynamic prefabs The `00_Preloading Dynamic Prefabs` scene is the simplest implementation of a dynamic Prefab. It instructs all game instances to load a network Prefab (it can be just one, it can also be a set of network Prefabs) and inject them to a NetworkManager's NetworkPrefabs list before starting the server. What's important is that it doesn't matter where the Prefab comes from. It can be a simple Prefab or it can be an Addressable - it's all the same. @@ -115,8 +116,10 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blo After the client loads the necessary Prefabs, it once again transitions to the `ClientConnectingState`, and retries the connection to the server, sending along a new Prefab hash. -> [!NOTE] -> This sample leveraged a state machine to handle connection management. A state machine isn't by any means necessary for connection approvals to work—it serves to compartmentalize connection logic per state, and to be a debug-friendly tool to step through connection steps. +:::note +**Note**: This sample leveraged a state machine to handle connection management. A state machine isn't by any means necessary for connection approvals to work—it serves to compartmentalize connection logic per state, and to be a debug-friendly tool to step through connection steps. + +::: ### Scene 02_Server Authoritative Load All Prefabs Asynchronously @@ -164,7 +167,7 @@ The server records that the client has successfully loaded the dynamic Prefab. A ### Scene 03_Server Authoritative Synchronous Dynamic Prefab Spawn -The `03_Server Authoritative Synchronous Dynamic Prefab Spawn` scene is a dynamic Prefab loading scenario where the server instructs all clients to load a single network Prefab, and only invokes a spawn after all clients have finish loading the Prefab. The server initially sends a [ClientRpc](../../../docs/advanced-topics/message-system/clientrpc.md) to all clients, begins loading the Prefab on the server, awaits a acknowledgement of a load via a [ServerRpcs](../../../docs/advanced-topics/message-system/serverrpc.md) from each client, and only spawns the Prefab over the network after it receives an acknowledgement from every client, within a predetermined amount of time. +The `03_Server Authoritative Synchronous Dynamic Prefab Spawn` scene is a dynamic Prefab loading scenario where the server instructs all clients to load a single network Prefab, and only invokes a spawn after all clients have finish loading the Prefab. The server initially sends an [RPC](../../advanced-topics/message-system/rpc.md) to all clients, begins loading the Prefab on the server, awaits a acknowledgement of a load via an RPC from each client, and only spawns the Prefab over the network after it receives an acknowledgement from every client, within a predetermined amount of time. This example implementation works best for scenarios where you want to guarantee the same world version across all connected clients. Because the server waits for all clients to finish loading the same dynamic Prefab, the spawn of said dynamic Prefab will be synchronous. @@ -214,7 +217,7 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blo ### Scene 04_Server Authoritative Spawn Dynamic Prefab Using Network Visibility -The `04_Server Authoritative Spawn Dynamic Prefab Using Network Visibility` scene is a dynamic Prefab loading scenario where the server instructs all clients to load a single network Prefab via a [ClientRpc](../../../docs/advanced-topics/message-system/clientrpc.md), spawns the Prefab as soon as it's loaded on the server, and marks the Prefab as network-visible only to clients that have already loaded that same Prefab. As soon as a client loads the Prefab locally, it sends an acknowledgement [ServerRpcs](../../../docs/advanced-topics/message-system/serverrpc.md), and the server marks that spawned NetworkObject as network-visible for that client. +The `04_Server Authoritative Spawn Dynamic Prefab Using Network Visibility` scene is a dynamic Prefab loading scenario where the server instructs all clients to load a single network Prefab via an RPC, spawns the Prefab as soon as it's loaded on the server, and marks the Prefab as network-visible only to clients that have already loaded that same Prefab. As soon as a client loads the Prefab locally, it sends an acknowledgement RPC, and the server marks that spawned NetworkObject as network-visible for that client. An important implementation detail to note about this technique is that the server won't wait until all clients load a dynamic Prefab before spawning the corresponding NetworkObject. As a result, a NetworkObject becomes network-visible for a connected client as soon as the client loads it—a client isn't blocked by the loading operation of another client (which might take longer to load the asset or fail to load it at all). A consequence of this asynchronous loading technique is that clients might experience differing world versions momentarily. As a result, it's not recommend to use this technique for spawning game-changing gameplay elements (like a boss fight, for example) if you want all clients to interact with the spawned NetworkObject as soon as the server spawns it. diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-introduction.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-introduction.md similarity index 54% rename from com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-introduction.md rename to com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-introduction.md index 809f3db375..159df67a98 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-introduction.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-introduction.md @@ -2,10 +2,11 @@ The Bitesize Samples repository provides a series of sample code as modules to use in your games and better understand Netcode for GameObjects (Netcode). -* [2D Space Shooter Sample](bitesize-spaceshooter.md) - Learn more about physics movement and status effects using Netcode `NetworkVariables` and `ObjectPooling`. -* [Invaders Sample](bitesize-invaders.md) - Learn more about game flow, modes, unconventional movement networked, and a shared timer. -* [Client Driven Sample](bitesize-clientdriven.md) - Learn more about Client driven movements, networked physics, spawning vs statically placed objects, object reparenting. -* [Dynamic Addressables Network Prefabs](bitesize-dynamicprefabs.md) - Learn more about the dynamic prefab system, which allows us to add new spawnable prefabs at runtime. +* [Multiplayer Use Cases](bitesize-usecases.md) - Learn more about core Netcode For GameObjects (Netcode) features through practical examples and In-Editor tutorials. +* [2D Space Shooter](bitesize-spaceshooter.md) - Learn more about physics movement and status effects using Netcode `NetworkVariables` and `ObjectPooling`. +* [Invaders](bitesize-invaders.md) - Learn more about game flow, modes, unconventional movement networked, and a shared timer. +* [Client Driven](bitesize-clientdriven.md) - Learn more about Client driven movements, networked physics, spawning vs statically placed objects, object reparenting. +* [Dynamic Addressables Network Prefabs](bitesize-dynamicprefabs.md) - Learn more about the dynamic prefab system, which allows you to add new spawnable prefabs at runtime. ## Requirements @@ -17,7 +18,7 @@ You need Unity and Netcode for GameObjects installed to work with these samples. Download the project files from the [Bitesize Samples Repository](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize) -![how to download](../images/bitesize/bitesize-download.png) +![how to download](../../images/bitesize/bitesize-download.png) After download, unzip the archive file. You are now ready to add the project to Unity Hub. @@ -27,8 +28,9 @@ After download, unzip the archive file. You are now ready to add the project to 1. Click **Add**. 1. Navigate to the unzipped folder. select the one of the projects in the `Basic` folder to add the respective project. -> [!NOTE] Compatibility -> The Bitesize Samples have been built for a specific Unity version. You can see the version after adding a sample to the Unity Hub or in the description of the [repository](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize). We recommend using the same Unity version to avoid potential issues. +:::important Compatibility +The Bitesize Samples have been built for a specific Unity version. You can see the version after adding a sample to the Unity Hub or in the description of the [repository](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize). We recommend using the same Unity version to avoid potential issues. +::: ## Troubleshooting diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-invaders.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-invaders.md similarity index 94% rename from com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-invaders.md rename to com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-invaders.md index 6a06a08983..c000aeac23 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-invaders.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-invaders.md @@ -1,6 +1,10 @@ -# Invaders sample +--- +id: bitesize-invaders +title: Invaders sample +description: Learn more about game flow, modes, unconventional movement networked, and a shared timer using Netcode for GameObjects. +--- -The [Invaders Sample Project](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/main/Basic/Invaders) to understand the game flow and modes with Netcode for GameObjects (Netcode) using Scene Management, Unconventional Movement Networked, and a Shared Timer between clients updated client-side with server side seeding. +The [Invaders Sample Project](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/tree/main/Deprecated/Invaders) to understand the game flow and modes with Netcode for GameObjects (Netcode) using Scene Management, Unconventional Movement Networked, and a Shared Timer between clients updated client-side with server side seeding. ## Game Flows @@ -40,8 +44,9 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blo One example of how to update the current `SceneState` is in *[InvadersGame.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/v1.2.1/Basic/Invaders/Assets/Scripts/InvadersGame.cs)*, in the `OnNetworkSpawn` function. -> [!NOTE] -> This class has the same role as the Lobby Controller, it acts as a Manager, for a specific part of the game. +:::note +This class has the same role as the Lobby Controller, it acts as a Manager, for a specific part of the game. +::: ```csharp reference https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/v1.2.1/Basic/Invaders/Assets/Scripts/InvadersGame.cs#L156-L194 diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-landing.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-landing.md new file mode 100644 index 0000000000..b75e2d73f0 --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-landing.md @@ -0,0 +1,11 @@ +# Bite Size samples + +The Bite Size samples are small, focused examples that demonstrate specific features or patterns in Unity Netcode for GameObjects. They are designed to be quick to set up and easy to understand, making them ideal for learning and experimentation. + +| **Topic** | **Description** | +| :------------------------------ | :------------------------------- | +| **[Bitesize use cases](bitesize-usecases.md)** | The [Multiplayer Use Cases Sample](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/tree/main/Basic/MultiplayerUseCases) provides multiple scenes that explain some APIs, systems, and concepts that you can use with Netcode for GameObjects: | +| **[Bitesize introduction](bitesize-introduction.md)** | The Bitesize Samples repository provides a series of sample code as modules to use in your games and better understand Netcode for GameObjects. | +| **[Bitesize space shooter](bitesize-spaceshooter.md)** | Learn more about physics movement and status effects using Netcode for GameObjects (Netcode) NetworkVariables and ObjectPooling. | +| **[Bitesize client driven](bitesize-clientdriven.md)** | Learn more about Client driven movements, networked physics, spawning vs statically placed objects, object reparenting. | +| **[Bitesize dynamic prefabs](bitesize-dynamicPrefabs.md)** | Learn more about the dynamic Prefab system, which allows you to add new spawnable Prefabs at runtime. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-spaceshooter.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-spaceshooter.md similarity index 90% rename from com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-spaceshooter.md rename to com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-spaceshooter.md index ef848a7b5b..624a837633 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bitesize/bitesize-spaceshooter.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-spaceshooter.md @@ -38,9 +38,9 @@ The `2DSpaceShooter` object creates many objects dynamically at runtime includin 2DSpaceShooter uses the NetworkObjectPool script, which can be found in the Community Contributions Repository. -![pool img](../images/bitesize/invader-networkobjectpool.png) +![pool img](../../images/bitesize/invader-networkobjectpool.png) -All of the runtime spawnable objects have been registered to the pool. On the client-side, this will cause Netcode to use an object from the pool instead of instantiating a new Object. When the `NetworkObject` is despawned, it will be automatically returned to the pool instead of getting destroyed. +All of the runtime spawnable objects have been registered to the pool. On the client-side, this will cause Netcode to use an object from the pool instead of instantiating a new Object. When the NetworkObject is despawned, it will be automatically returned to the pool instead of getting destroyed. Adding the `NetworkObjectPool` to the scene won't yet pool server objects because these must be manually created and then spawned by the user. Instead of instantiating objects, your code should take them from the pool. @@ -60,5 +60,6 @@ powerUp.GetComponent().Spawn(null, true); -> [!NOTE] -> If you are using Unity 2021, you can use the built-in [Object Pooling API](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/Pool.ObjectPool_1.html) instead to build your own object pools. +:::tip +If you are using Unity 2021, you can use the built-in [Object Pooling API](https://docs.unity3d.com/2021.1/Documentation/ScriptReference/Pool.ObjectPool_1.html) instead to build your own object pools. +::: diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-usecases.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-usecases.md new file mode 100644 index 0000000000..ebdbfc5705 --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-usecases.md @@ -0,0 +1,50 @@ +# Multiplayer Use Cases sample + +The [Multiplayer Use Cases Sample](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/tree/main/Basic/MultiplayerUseCases) provides multiple scenes that explain some APIs, systems, and concepts that you can use with Netcode for GameObjects: + +- Server-side manipulation of data sent by Clients. +- State synchronization through NetworkVariables. +- Proximity interactions that are only visible only to the local player. +- Client-server communication through Remote Procedure Calls (RPCs). + +### Tutorials + +Each scene includes a tutorial to help you locate the scripts and GameObjects it uses. Follow the tutorial included in each sample scene to learn how to use it. + +The tutorials that open with each scene use the [Tutorial Framework package](https://docs.unity3d.com/Packages/com.unity.learn.iet-framework@4.0/manual/index.html). You can open each tutorial at any time from the **Tutorials** menu. + +## The Anticipation scene + +The Anticipation scene demonstrates the Client Anticipation feature of Netcode for GameObjects in the following use cases: +- [`AnticipatedNetworkVariable`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@2.2/api/Unity.Netcode.AnticipatedNetworkVariable-1.html): + - Anticipate server actions based on player interaction to change NetworkVariables responsively. + - Compensate for latency that the server causes when it changes a value. + - Handle incorrect anticipation. +- [`AnticipatedNetworkTransform`](https://docs.unity3d.com/Packages/com.unity.netcode.gameobjects@2.2/api/Unity.Netcode.Components.AnticipatedNetworkTransform.html): + - Responsive server-authoritative player movement. + - Smooth player movement across clients. + +## The NetvarVsRpc scene + +The NetvarVsRpc scene explains why to use NetworkVariables instead of Remote Procedure Calls (RPCs) to perform state synchronization. + +## The NetworkVariables scene + +The NetworkVariables scene shows you how to use NetworkVariables to perform state synchronization in a way that also sends the most recent information to late joining or reconnecting clients. + +## The ProximityChecks scene + +The ProximityChecks scene shows you how to detect the local user and enable or disable in-game actions based on the player character's distance from a GameObject. + +## The RPCs scene + +The RPCs scene demonstrates the following Remote Procedure Call (RPC) processes: + * Use RPCs to send information from clients to the server. + * Perform server-side manipulation of the data sent. + * Use connection approval to determine the spawn position of the player. + +## Additional resources + +- Get help and ask questions on [Multiplayer Discussions](https://discussions.unity.com/lists/multiplayer). +- Join the community of Multiplayer creators on the [Multiplayer Networking Discord](https://discord.gg/unity-multiplayer-network). +- [Request a feature or report a bug](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/issues/new/choose). diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/architecture.md b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/architecture.md similarity index 81% rename from com.unity.netcode.gameobjects/Documentation~/learn/bossroom/architecture.md rename to com.unity.netcode.gameobjects/Documentation~/samples/bossroom/architecture.md index 4a0970524d..0f0928e5a7 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/architecture.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/architecture.md @@ -12,14 +12,15 @@ An exception to this organization structure is the Gameplay assembly, which hous This assembly separation style enforces better separation of concerns and helps keep the codebase organized. It also uses more granular recompilation during iterations to save time. -![Assembly structure](../images/arch-2.png) +![Assembly structure](../../images/arch-2.png) ## Application flow The application flow of Boss Room starts with the `Startup` scene (which should always load first). -> [!NOTE] -> The Boss Room sample has an editor tool that enforces starting from the `Startup` scene even if you're working in another scene. You can disable this tool through the Unity Editor by selecting **Menu** > **Boss Room** > **Don't Load Bootsrap Scene On Play**. Select **Load Bootsrap Scene On Play** to re-enable it. +:::tip +The Boss Room sample has an editor tool that enforces starting from the `Startup` scene even if you're working in another scene. You can disable this tool through the Unity Editor by selecting **Menu** > **Boss Room** > **Don't Load Bootstrap Scene On Play**. Select **Load Bootstrap Scene On Play** to re-enable it. +::: The `ApplicationController` component lives on a GameObject in the Startup scene and serves as the application's entry point (and composition root). It binds dependencies throughout the application's lifetime (the core dependency injection managed “singletons”). See the [Dependency Injection](#dependency-injection) section for more information. @@ -35,11 +36,11 @@ The `NetworkManager` starts when the `CharSelect` scene loads, which happens whe ### Application Flow Diagram -![Application Flow Diagram](../images/arch-1.png) +![Application Flow Diagram](../../images/arch-1.png) -> [!NOTE] +:::note Boss Room's main room has four scenes. The primary scene (Boss Room's root scene) has the state components, game logic, level `navmesh`, and trigger areas that let the server know to load a given sub-scene. Boss Room loads each sub-scene additively using those triggers. -> [!NOTE] +:::tip Sub-scenes contain spawn points for the enemies and visual assets for their respective level segments. The server unloads sub-scenes that don't have active players and loads the required sub-scenes based on the players' position. If at least one player overlaps with the sub-scene's trigger area, the server loads the sub-scene. @@ -52,7 +53,7 @@ Boss Room supports two network transport mechanisms: Clients connect directly to a host via an IP address when using IP. However, the IP network transport only works if the client and host are in the same local area network (or if the host uses port forwarding). -With the Unity Relay network transport, clients don't need to worry about sharing a local area network or port forwarding. However, you must first [set up the Relay service](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Documentation/Unity-Relay/README.md). +With the Unity Relay network transport, clients don't need to worry about sharing a local area network or port forwarding. However, you must first [set up the Relay service](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Documentation/Unity-Relay/README.md). See the [Multiplayer over the internet](getting-started-boss-room.md) section of the Boss Room README for more information about using the two network transport mechanisms. @@ -60,13 +61,13 @@ Boss Room uses the Unity Transport package. Boss Room's assigns its instance of The Unity Transport Package is a network transport layer with network simulation tools that help spot networking issues early during development. Boss Room has both buttons to start a game in the two modes and will setup Unity Transport automatically to use either one of them at runtime. -Unity Transport supports Unity Relay (provided by Unity Gaming Services). See the documentation on [Unity Transport package](../../../transport/about.md) and [Unity Relay](https://docs-multiplayer.unity3d.com/docs/relay/relay) for more information. +Unity Transport supports Unity Relay (provided by Unity Gaming Services). See the documentation on [Unity Transport package](https://docs.unity3d.com/Packages/com.unity.transport@latest?subfolder=/manual/index.html) and [Unity Relay](https://docs-multiplayer.unity3d.com/docs/relay/relay) for more information. ## Connection flow state machine The `ConnectionManager`, a simple state machine, owns Boss Room's network connection flow. It receives inputs from Netcode for GameObjects (or the user) and handles the inputs according to its current state. Each state inherits from the `ConnectionState` abstract class. If you add a new transport, you must extend the `StartingHostState` and `ClientConnectingState` states. Both of these classes assume you're using the Unity Transport transport. -![Connection flow state machine](../images/arch-3.png) +![Connection flow state machine](../../images/arch-3.png) ## Session management and reconnection @@ -86,22 +87,24 @@ These three UGS services allow players to host and join games without needing po To keep a single source of truth for service access (and avoid scattering of service access logic), Boss Room wraps UGS SDK access into `Facades` and uses UI mediators to contain the service logic triggered by user interfaces (UIs). -* [`AuthenticationServiceFacade.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/UnityServices/Auth/AuthenticationServiceFacade.cs) -* [`LobbyServiceFacade.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/UnityServices/Lobby/LobbyServiceFacade.cs) -* Lobby and Relay - client join - `JoinLobbyRequest()` in [Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs) -* Relay Join - `StartClientLobby()` in [Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs) -* Relay Create - `StartHostLobby()` in [Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs) -* Lobby and Relay - host creation - `CreateLobbyRequest()` in [Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs) +* [`AuthenticationServiceFacade.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/UnityServices/Auth/AuthenticationServiceFacade.cs) +* [`LobbyServiceFacade.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/UnityServices/Lobbies/LobbyServiceFacade.cs) +* Lobby and Relay - client join - `JoinLobbyRequest()` in [Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs) +* Relay Join - `StartClientLobby()` in [Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs) +* Relay Create - `StartHostLobby()` in [Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs) +* Lobby and Relay - host creation - `CreateLobbyRequest()` in [Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs) ## Core gameplay structure -> [!NOTE] -> An `Avatar` is at the same level as an `Imp` and lives in a scene. A `Persistent Player` lives across scenes. +:::note +An `Avatar` is at the same level as an `Imp` and lives in a scene. A `Persistent Player` lives across scenes. +::: A `Persistent Player` Prefab goes into the `Player` Prefab slot in the `NetworkManager` of Boss Room. As a result, Boss Room spawns a single `Persistent Player` Prefab per client, and each client owns their respective `Persistent Player` instances. -> [!NOTE] -> There is no need to mark `Persistent Player` instances as `DontDestroyOnLoad`. Netcode for GameObjects automatically keeps these prefabs alive between scene loads while the connections are live. +:::note +There is no need to mark `Persistent Player` instances as `DontDestroyOnLoad`. Netcode for GameObjects automatically keeps these prefabs alive between scene loads while the connections are live. +::: The `Persistent Player` Prefab stores synchronized data about a player, such as their name and selected `PlayerAvatar` GUID. @@ -113,7 +116,7 @@ Inside the Boss Room scene, `ServerBossRoomState` spawns a `PlayerAvatar` per `P The following example of a selected “Archer Boy” class shows the `PlayerAvatar` GameObject hierarchy: -* `PlayerAvatar` is a `NetworkObject` that Boss Room destroys when the scene unloads. +* `PlayerAvatar` is a NetworkObject that Boss Room destroys when the scene unloads. * `PlayerGraphics` is a child `GameObject` containing a `NetworkAnimator` component responsible for replicating animations invoked on the server. * `PlayerGraphics_Archer_Boy` is a purely graphical representation of the selected avatar class. @@ -133,16 +136,17 @@ The following example of a selected “Archer Boy” class shows the `PlayerAvat We defined Boss Room's game configuration using ScriptableObjects. -The [`GameDataSource.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/RuntimeDataContainers/GameDataSource.cs) singleton class stores all actions and character classes in the game. +The [`GameDataSource.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/RuntimeDataContainers/GameDataSource.cs) singleton class stores all actions and character classes in the game. -[`CharacterClass`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Configuration/CharacterClass.cs) is the data representation of a Character and has elements such as starting stats and a list of Actions the character can perform. It covers both player characters and non-player characters (NPCs) alike. +[`CharacterClass`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Configuration/CharacterClass.cs) is the data representation of a Character and has elements such as starting stats and a list of Actions the character can perform. It covers both player characters and non-player characters (NPCs) alike. -The [`Action`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Configuration/Action.cs) subclasses are data-driven and represent discrete verbs, such as swinging a weapon or reviving a player. +The [`Action`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Configuration/Action.cs) subclasses are data-driven and represent discrete verbs, such as swinging a weapon or reviving a player. ### Action System -> [!NOTE] -> Boss Room's action system was created specifically for Boss Room's educational purpose. You'll need to implement a more user friendly custom action system to allow for better game design emergence from your game designers. +:::note +Boss Room's action system was created specifically for Boss Room's educational purpose. You'll need to implement a more user friendly custom action system to allow for better game design emergence from your game designers. +::: Boss Room's Action System is a generalized mechanism for `Characters` to "do stuff" in a networked way. `ScriptableObject`-derived `Actions` implement the client and server logic of any given thing the characters can do in the game. @@ -152,14 +156,15 @@ Each character can have multiple actions that exist simultaneously but only one Boss Room synchronizes actions by calling a `ServerCharacter.RecvDoActionServerRPC` and passing the `ActionRequestData`, a struct that implements the `INetworkSerializable` interface. -> [!NOTE] -> `ActionRequestData` has an `ActionID` field, a simple struct that wraps an integer containing the index of a given `ScriptableObject` `Action` in the registry of abilities available to characters. The registry of available character abilities is stored in `GameDataSource`. +:::note +`ActionRequestData` has an `ActionID` field, a simple struct that wraps an integer containing the index of a given `ScriptableObject` `Action` in the registry of abilities available to characters. The registry of available character abilities is stored in `GameDataSource`. +::: Boss Room uses the `ActionID` struct to reconstruct the requested action and play it on the server by creating a pooled clone of the `ScriptableObject` `Action` that corresponds to the action. Clients then play out the visual part of the ability (including particle effects and projectiles). It's also possible to play an anticipatory animation on the client requesting an ability. For instance, you might want to play a small jump animation when the character receives movement input but hasn't yet moved (because it hasn't synchronized the data from the server). -[`ServerActionPlayer`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ActionPlayers/ServerActionPlayer.cs) and [`ClientActionPlayer`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ActionPlayers/ClientActionPlayer.cs) are companion classes to actions Boss Room uses to play out the actions on both the client and server. +[`ServerActionPlayer`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ActionPlayers/ServerActionPlayer.cs) and [`ClientActionPlayer`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ActionPlayers/ClientActionPlayer.cs) are companion classes to actions Boss Room uses to play out the actions on both the client and server. #### Movement action flow @@ -175,8 +180,9 @@ The following list describes the movement flow of a player character. 8. There's network latency before clients receive replication data. 9. The client representation of the entity updates its NetworkVariables. -> [!NOTE] -> The Visuals GameObject never outpaces the simulation GameObject and is always slightly behind the networked position and rotation. +:::note +The Visuals GameObject never outpaces the simulation GameObject and is always slightly behind the networked position and rotation. +::: ### Navigation system @@ -198,8 +204,9 @@ Boss Room implements the [Dependency Injection](https://en.wikipedia.org/wiki/De DI also allows Boss Room to circumvent the problem of cross-scene references to common dependencies, even though it still has to manage the lifecycle of `MonoBehaviour`-based dependencies by marking them with `DontDestroyOnLoad` and destroying them manually when appropriate. -> [!NOTE] -> `ApplicationController` inherits from the `VContainer`'s `LifetimeScope`, a class that serves as a dependency injection scope and bootstrapper that facilitates binding dependencies. Scene-specific State classes inherit from `LifetimeScope`, too. +:::note +`ApplicationController` inherits from the `VContainer`'s `LifetimeScope`, a class that serves as a dependency injection scope and bootstrapper that facilitates binding dependencies. Scene-specific State classes inherit from `LifetimeScope`, too. +::: In the Unity Editor Inspector, you can choose a parent scope for any `LifetimeScope`. When doing so, it's helpful to set a cross-scene reference to some parent scopes, most commonly the `ApplicationController`. Setting a cross-scene reference allows you to bind scene-specific dependencies while maintaining easy access to the global dependencies of the `ApplicationController` in the State-specific version of a `LifetimeScope` object. @@ -252,8 +259,9 @@ These mechanisms allow for strong separation of concerns and coupling reduction `MessageChannel` classes implement the `IPublisher` and `ISubscriber` interfaces and have the actual messaging logic. -> [!NOTE] -> The Boss Room development team considered using a third party library for messaging (like `MessagePipe`). However, since Boss Room needed custom networked channels and the use cases were quite simple, the team decided to go with an in-house light implementation. If Boss Room was a full game with more gameplay, it'd benefit more from a library that with more features. +:::note +The Boss Room development team considered using a third party library for messaging (like `MessagePipe`). However, since Boss Room needed custom networked channels and the use cases were quite simple, the team decided to go with an in-house light implementation. If Boss Room was a full game with more gameplay, it'd benefit more from a library that with more features. +::: #### `NetworkedMessageChannel` diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/bossroom-actions.md b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/bossroom-actions.md new file mode 100644 index 0000000000..f59f9c017c --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/bossroom-actions.md @@ -0,0 +1,48 @@ +# Boss Room actions walkthrough + +Boss Room's actions each use a different pattern for good multiplayer quality. This doc walks you through each of them and goes into details about how we implemented each and what lessons you can learn from each. You can get their implementations [here](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/tree/main/Assets/Scripts/Gameplay/Action). + +
+ +
Playing an anticipatory animation on the owner client to appear reactive and hide Network Latency.
+
+ + + +
+ +
Boss Room's mage's bolt doesn't use NetworkVariables and NetworkObjects to track the bolt's state. Since its movement is fast, we only send an RPC to trigger VFX on clients. No need to waste CPU and bandwidth on a NetworkObject over time for this. Even if the FX passes through a wall on some clients (due to network discrepancies in target positions), the FX is so quick it wouldn't be visible to players.
+
+ +
+ +
Boss Room's archer's arrows use fully replicated NetworkObjects + NetworkTransform. Since they're slow moving, we want them to be seen by late joining players. We also want to make sure their behaviour is the same for all clients (so they don't go through walls for example). This will use more bandwidth, but will be more accurate.
+
+
+ +
The archer's volley takes multiple steps. First on click, the client will show a circle VFX tracking the mouse. That FX isn't networked and client side only. Then on click, the client will send an RPC to the server. The server will then apply it's gameplay logic, update the imp's health (tracked by NetworkVariables) and trigger a Client RPC to play the volley animation on all clients.
+
+ + + +
+ +
Emotes only use RPCs. We don't care if a late joining player doesn't see other player's emotes.
+
+ +
+ +
Most of the rogue sneak's logic happens server side. Since Boss Room is a coop game, we're not using Network invisibility here, only client side effects. Clients will still receive that invisible player's information and imp AIs will ignore invisible players.
+
diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/bossroom-landing.md b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/bossroom-landing.md new file mode 100644 index 0000000000..17fa647b31 --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/bossroom-landing.md @@ -0,0 +1,12 @@ +# Boss Room sample + +The Boss Room sample is a multiplayer game that demonstrates how to use Netcode for GameObjects to create a networked game. It provides a complete example of how to implement various features such as player movement, combat, and game state management in a multiplayer environment. + +| **Topic** | **Description** | +| :------------------------------ | :------------------------------- | +| **[Boss Room](getting-started-boss-room.md)** | Boss Room is a fully functional co-op multiplayer RPG made with Unity Netcode. It's an educational sample designed to showcase typical netcode [patterns](bossroom-actions.md) often featured in similar multiplayer games. | +| **[Boss Room architecture](architecture.md)** | This article describes the high-level architecture of the Boss Room codebase and dives into some reasoning behind architectural decisions. | +| **[NetworkObject parenting](networkobject-parenting.md)** | Understand how NetworkObjects are parented in the Boss Room sample. | +| **[Optimizing Boss Room](optimizing-bossroom.md)** | Understand how performance is optimized in the Boss Room sample. | +| **[NetworkRigidbody](networkrigidbody.md)** | Understand how NetworkRigidbody is used in the Boss Room sample. | +| **[Spawn NetworkObjects](spawn-networkobjects.md)** | Understand how NetworkObjects are spawned in the Boss Room sample. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/getting-started-boss-room.md b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/getting-started-boss-room.md similarity index 65% rename from com.unity.netcode.gameobjects/Documentation~/learn/bossroom/getting-started-boss-room.md rename to com.unity.netcode.gameobjects/Documentation~/samples/bossroom/getting-started-boss-room.md index 01fdd3e9af..b1f8860931 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/getting-started-boss-room.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/getting-started-boss-room.md @@ -1,11 +1,9 @@ # Getting started with Boss Room -![Boss Room banner](../images/banner.png) - -Boss Room is a fully functional co-op multiplayer RPG made with Unity Netcode. it's an educational sample designed to showcase typical netcode [patterns](https://docs-multiplayer.unity3d.com/netcode/current/learn/bossroom/bossroom-actions/index.html) often featured in similar multiplayer games. +Boss Room is a fully functional co-op multiplayer RPG made with Unity Netcode. It's an educational sample designed to showcase typical netcode [patterns](bossroom-actions.md) often featured in similar multiplayer games. > [!NOTE] -> Boss Room is compatible with the latest Unity Long Term Support (LTS) Editor version (currently [2022 LTS](https://unity.com/releases/lts)). Make sure to include standalone support for Windows/Mac in your installation. +> Boss Room is compatible with the latest Unity Long Term Support (LTS) Editor version (currently [6000 LTS](https://unity.com/releases). Make sure to include standalone support for Windows/Mac in your installation. Boss Room has been developed and tested on the following platforms: @@ -23,10 +21,9 @@ Join the multiplayer community on the Unity [Discord](https://discord.gg/mNgM2XR ### Contents and quick links -- [Contents and quick links](#contents-and-quick-links) - [Boss Room Overview](#boss-room-overview) -- [Getting the project](#getting-the-project) - - [Installing Git LFS to clone locally](#installing-git-lfs-to-clone-locally) +- [Install the Boss Room project](#getting-the-project) + - [Install Git LFS to clone locally](#installing-git-lfs-to-clone-locally) - [Direct download](#direct-download) - [Registering the project with Unity Gaming Services (UGS)](#registering-the-project-with-unity-gaming-services-ugs) - [Opening the project for the first time](#opening-the-project-for-the-first-time) @@ -44,8 +41,6 @@ Join the multiplayer community on the Unity [Discord](https://discord.gg/mNgM2XR - [Bugs](#bugs) - [Licence](#licence) - [Other samples](#other-samples) -- [Contributing](#contributing) -- [Feedback form](#feedback-form) ### Boss Room Overview @@ -53,19 +48,21 @@ Boss Room is designed to be used in its entirety to help you explore the concept You can use the project as a reference starting point for your own Unity game or use elements individually. -This repository also has a [Utilities](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop) package containing reusable sample scripts. You can install it using the following manifest file entry: +This repository also has a [Utilities](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop) package containing reusable sample scripts. You can install it using the following manifest file entry: ```json "com.unity.multiplayer.samples.coop": "https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git?path=/Packages/com.unity.multiplayer.samples.coop" ``` -For more information on the art in Boss Room, see [ART_NOTES.md](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Documentation/ART_NOTES.md). +For more information on the art in Boss Room, see [ART_NOTES.md](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Documentation/ART_NOTES.md). + +### Install the Boss Room project -### Getting the project +To install the Boss Room project, download or clone it from the [com.unity.multiplayer.samples.coop](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop) repository. -You can get the project by downloading it directly or cloning locally. However, if you use git, you must install Git LFS. +**Note**: If you install the project with Git, you must install Git LFS first. -#### Installing Git LFS to clone locally +#### Install Git LFS to clone locally Boss Room uses Git Large Files Support (LFS) to handle all large assets required locally. See [Git LFS installation options](https://github.com/git-lfs/git-lfs/wiki/Installation) for Windows and Mac instructions. This step is only needed if cloning locally. You can also just download the project which will already include large files. @@ -73,10 +70,11 @@ Boss Room uses Git Large Files Support (LFS) to handle all large assets required You can download the latest version of Boss Room from our [Releases](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/releases) page. Doing so doesn't require you to use Git LFS. -Alternatively, you can click the green **Code** button, then select **Download Zip**. This downloadd the branch that you are currently viewing on Github. +Alternatively, you can click the green **Code** button on the main "Code" github page, then select **Download Zip**. This downloads the branch that you are currently viewing on Github. -> [!NOTE] -> **Note for Windows users**: Using Windows' built-in extraction tool may generate an `Error 0x80010135: Path too long` error window which can invalidate the extraction process. A workaround for this is to shorten the zip file to a single character (for example, "`c.zip`") and move it to the shortest path on your computer (most often right at `C:\`) and retry. If that solution fails, another workaround is to extract the downloaded zip file using [7zip](https://www.7-zip.org/). +:::note +**Note for Windows users**: Using Windows' built-in extraction tool may generate an `Error 0x80010135: Path too long` error window which can invalidate the extraction process. A workaround for this is to shorten the zip file to a single character (for example, "`c.zip`") and move it to the shortest path on your computer (most often right at `C:\`) and retry. If that solution fails, another workaround is to extract the downloaded zip file using [7zip](https://www.7-zip.org/). +::: ### Registering the project with Unity Gaming Services (UGS) @@ -86,7 +84,7 @@ Boss Room leverages several services from UGS to ease connectivity between playe Once you have downloaded the project, follow the steps below to get up and running: -1. Check that you have installed the most recent [LTS editor version](https://unity.com/releases/lts). +1. Check that you have installed the most recent [LTS editor version](https://unity.com/releases/). 1. Include standalone support for **Windows/Mac** in your Unity Editor installation. 2. Add the project to the Unity Hub by selecting the **Add** button and pointing it to the root folder of the downloaded project. 1. Unity imports all the project assets the first time you open the project, which takes longer than usual. @@ -115,14 +113,15 @@ See [Testing multiplayer games locally](../../tutorials/testing/testing_locally. #### Local multiplayer setup -First, build an executable by selecting **File** > **Build Settings** > **Build**. +First, build an executable by selecting **File** > **Build Profiles** > **Build**. After you have the build, you can launch several instances of the build executable to host or join a game. If you run several instances locally, you must use the **Change Profile** button to set different profiles for each instance for authentication purposes. -> [!NOTE] -> If you're using Mac to run multiple instances of the same app, you need to use the command line. Run `open -n BossRoom.app`. +:::note +**Note**: If you're using Mac to run multiple instances of the same app, you need to use the command line. Run `open -n BossRoom.app`. +::: #### Multiplayer over Internet @@ -130,8 +129,9 @@ Use the following instructions to test Boss Room with multiple players over the First, build an executable and distribute it to all players. -> [!NOTE] -> It's possible to connect between multiple instances of the same executable OR between executables and the Unity Editor that you used to create the executable. +:::tip +**Tip**: it's possible to connect between multiple instances of the same executable OR between executables and the Unity Editor that you used to create the executable. +::: Next, you need to set up a relay. Running the Boss Room over the internet currently requires setting up a relay: @@ -148,83 +148,83 @@ The Boss Room sample includes resources for gameplay, game flow, connectivity, U Boss Room includes the following gameplay resources: -* Action anticipation - AnticipateActionClient() in [Assets/Scripts/Gameplay/Action/Action.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/Action.cs) -* Object spawning for long actions (archer arrow) - LaunchProjectile() in [Assets/Scripts/Gameplay/Action/ConcreteActions/LaunchProjectileAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/LaunchProjectileAction.cs) -* Quick actions with RPCs (ex: mage bolt) - [Assets/Scripts/Gameplay/Action/ConcreteActions/FXProjectileTargetedAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/FXProjectileTargetedAction.cs) -* Teleport - [Assets/Scripts/Gameplay/Action/ConcreteActions/DashAttackAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/DashAttackAction.cs) -* Client side input tracking before an action (archer AOE) - OnStartClient() in [Assets/Scripts/Gameplay/Action/ConcreteActions/AOEAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/AOEAction.cs) -* Time based action (charged shot) - [Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedLaunchProjectileAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedLaunchProjectileAction.cs) -* Object parenting to animation - [Assets/Scripts/Gameplay/Action/ConcreteActions/PickUpAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/PickUpAction.cs) -* Physics object throwing (using NetworkRigidbody) - [Assets/Scripts/Gameplay/Action/ConcreteActions/TossAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/TossAction.cs) -* NetworkAnimator usage - All actions, in particular [Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedShieldAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedShieldAction.cs) -* NetworkTransform local space - [Assets/Scripts/Gameplay/GameplayObjects/ServerDisplacerOnParentChange.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/ServerDisplacerOnParentChange.cs) -* Dynamic imp spawning with portals - [Assets/Scripts/Gameplay/GameplayObjects/ServerWaveSpawner.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/ServerWaveSpawner.cs) -* In scene placed dynamic objects (imps) - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs) -* Static objects (non-destroyables like doors, switches, etc) - [Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs) +* Action anticipation - AnticipateActionClient() in [Assets/Scripts/Gameplay/Action/Action.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/Action.cs) +* Object spawning for long actions (archer arrow) - LaunchProjectile() in [Assets/Scripts/Gameplay/Action/ConcreteActions/LaunchProjectileAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/LaunchProjectileAction.cs) +* Quick actions with RPCs (ex: mage bolt) - [Assets/Scripts/Gameplay/Action/ConcreteActions/FXProjectileTargetedAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/FXProjectileTargetedAction.cs) +* Teleport - [Assets/Scripts/Gameplay/Action/ConcreteActions/DashAttackAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/DashAttackAction.cs) +* Client side input tracking before an action (archer AOE) - OnStartClient() in [Assets/Scripts/Gameplay/Action/ConcreteActions/AOEAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/AOEAction.cs) +* Time based action (charged shot) - [Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedLaunchProjectileAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedLaunchProjectileAction.cs) +* Object parenting to animation - [Assets/Scripts/Gameplay/Action/ConcreteActions/PickUpAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/PickUpAction.cs) +* Physics object throwing (using NetworkRigidbody) - [Assets/Scripts/Gameplay/Action/ConcreteActions/TossAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/TossAction.cs) +* NetworkAnimator usage - All actions, in particular [Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedShieldAction.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedShieldAction.cs) +* NetworkTransform local space - [Assets/Scripts/Gameplay/GameplayObjects/ServerDisplacerOnParentChange.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/ServerDisplacerOnParentChange.cs) +* Dynamic imp spawning with portals - [Assets/Scripts/Gameplay/GameplayObjects/ServerWaveSpawner.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/ServerWaveSpawner.cs) +* In scene placed dynamic objects (imps) - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs) +* Static objects (non-destroyables like doors, switches, etc) - [Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs) * State tracking with breakables, switch, doors - * [Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs) - * [Assets/Scripts/Gameplay/GameplayObjects/FloorSwitch.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/FloorSwitch.cs) - * [Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs) -* NetworkVariable with Enum - [Assets/Scripts/Gameplay/GameState/NetworkPostGame.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameState/NetworkPostGame.cs) -* NetworkVariable with custom serialization (GUID) - [Assets/Scripts/Infrastructure/NetworkGuid.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Infrastructure/NetworkGuid.cs) -* NetworkVariable with fixed string - [Assets/Scripts/Utils/NetworkNameState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Utils/NetworkNameState.cs) -* NetworkList with custom serialization (LobbyPlayerState) - [Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs) -* Persistent player (over multiple scenes) - [Assets/Scripts/Gameplay/GameplayObjects/PersistentPlayer.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/PersistentPlayer.cs) + * [Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/Breakable.cs) + * [Assets/Scripts/Gameplay/GameplayObjects/FloorSwitch.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/FloorSwitch.cs) + * [Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs) +* NetworkVariable with Enum - [Assets/Scripts/Gameplay/GameState/NetworkPostGame.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameState/NetworkPostGame.cs) +* NetworkVariable with custom serialization (GUID) - [Assets/Scripts/Infrastructure/NetworkGuid.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Infrastructure/NetworkGuid.cs) +* NetworkVariable with fixed string - [Assets/Scripts/Utils/NetworkNameState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Utils/NetworkNameState.cs) +* NetworkList with custom serialization (LobbyPlayerState) - [Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs) +* Persistent player (over multiple scenes) - [Assets/Scripts/Gameplay/GameplayObjects/PersistentPlayer.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/PersistentPlayer.cs) * Character logic (including player's avatar) - [Assets/Scripts/Gameplay/GameplayObjects/Character/ \ -Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/Character) -* Character movements - [Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs) -* Client driven movements - Boss Room is server driven with anticipation animation. See [Client Driven bitesize](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/tree/v2.1.0/Basic/ClientDriven) for client driven gameplay -* Player spawn - SpawnPlayer() in [Assets/Scripts/Gameplay/GameState/ServerBossRoomState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameState/ServerBossRoomState.cs) +Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/Character) +* Character movements - [Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs) +* Client driven movements - Boss Room is server driven with anticipation animation. See [Client Driven bitesize](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/tree/main/Basic/ClientDriven) for client driven gameplay +* Player spawn - SpawnPlayer() in [Assets/Scripts/Gameplay/GameState/ServerBossRoomState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameState/ServerBossRoomState.cs) #### Game flow Boss Room includes the following game flow resources: -* Application Controller - [Assets/Scripts/ApplicationLifecycle/ApplicationController.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/ApplicationLifecycle/ApplicationController.cs) -* Game flow state machine - All child classes in [Assets/Scripts/Gameplay/GameState/GameStateBehaviour.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameState/GameStateBehaviour.cs) -* Scene loading and progress sharing - [ackages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement) -* Synced UI with character select - [Assets/Scripts/Gameplay/GameState/ClientCharSelectState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameState/ClientCharSelectState.cs) +* Application Controller - [Assets/Scripts/ApplicationLifecycle/ApplicationController.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/ApplicationLifecycle/ApplicationController.cs) +* Game flow state machine - All child classes in [Assets/Scripts/Gameplay/GameState/GameStateBehaviour.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameState/GameStateBehaviour.cs) +* Scene loading and progress sharing - [ackages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement) +* Synced UI with character select - [Assets/Scripts/Gameplay/GameState/ClientCharSelectState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameState/ClientCharSelectState.cs) * In-game lobby (character selection) - [Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs \ -Assets/Scripts/Gameplay/GameState/ServerCharSelectState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs) -* Win state - [Assets/Scripts/Gameplay/GameState/PersistentGameState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/GameState/PersistentGameState.cs) +Assets/Scripts/Gameplay/GameState/ServerCharSelectState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs) +* Win state - [Assets/Scripts/Gameplay/GameState/PersistentGameState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/GameState/PersistentGameState.cs) #### Connectivity Boss Room includes the following connectivity resources: -* Connection approval return value with custom messaging - WaitToDenyApproval() in [Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs) +* Connection approval return value with custom messaging - WaitToDenyApproval() in [Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs) * Connection state machine - [Assets/Scripts/ConnectionManagement/ConnectionManager.cs \ -Assets/Scripts/ConnectionManagement/ConnectionState/](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/ConnectionManagement/ConnectionManager.cs) -* Session manager - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs) -* RTT stats - [Assets/Scripts/Utils/NetworkOverlay/NetworkStats.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Utils/NetworkOverlay/NetworkStats.cs) +Assets/Scripts/ConnectionManagement/ConnectionState/](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/ConnectionManagement/ConnectionManager.cs) +* Session manager - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs) +* RTT stats - [Assets/Scripts/Utils/NetworkOverlay/NetworkStats.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Utils/NetworkOverlay/NetworkStats.cs) #### Services Boss Room supports integration with Lobby, Relay, and Authentication (UAS). Boss Room includes the following service resources: -* Lobby and relay - host creation - CreateLobbyRequest() in [Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs) -* Lobby and relay - client join - JoinLobbyRequest() in [Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs) -* Relay Join - StartClientLobby() in [Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs) -* Relay Create - StartHostLobby() in [Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs) -* Authentication - EnsurePlayerIsAuthorized() in [Assets/Scripts/UnityServices/Auth/AuthenticationServiceFacade.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/UnityServices/Auth/AuthenticationServiceFacade.cs) +* Lobby and relay - host creation - CreateLobbyRequest() in [Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs) +* Lobby and relay - client join - JoinLobbyRequest() in [Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs) +* Relay Join - StartClientLobby() in [Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs) +* Relay Create - StartHostLobby() in [Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs) +* Authentication - EnsurePlayerIsAuthorized() in [Assets/Scripts/UnityServices/Auth/AuthenticationServiceFacade.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/UnityServices/Auth/AuthenticationServiceFacade.cs) #### Tools and utilities Boss Room includes the following tools and utilities: -* Networked message channel (inter-class and networked messaging) - [Assets/Scripts/Infrastructure/PubSub/NetworkedMessageChannel.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Infrastructure/PubSub/NetworkedMessageChannel.cs) -* Simple interpolation - [Assets/Scripts/Utils/PositionLerper.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Utils/PositionLerper.cs) -* Network Object Pooling - [Assets/Scripts/Infrastructure/NetworkObjectPool.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Infrastructure/NetworkObjectPool.cs) -* NetworkGuid - [Assets/Scripts/Infrastructure/NetworkGuid.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Infrastructure/NetworkGuid.cs) -* Netcode hooks - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetcodeHooks.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetcodeHooks.cs) -* Spawner for in-scene objects - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs) -* Session manager for reconnection - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs) -* Relay utils - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs) -* Client authority - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs) -* Scene utils with synced loading screens - [Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement) -* RNSM custom config - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/CustomNetStatsMonitorConfiguration.asset](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/CustomNetStatsMonitorConfiguration.asset) -* NetworkSimulator usage through UI - [Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs ](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs) -* ParrelSync - [Packages/manifest.json](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Packages/manifest.json) +* Networked message channel (inter-class and networked messaging) - [Assets/Scripts/Infrastructure/PubSub/NetworkedMessageChannel.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Infrastructure/PubSub/NetworkedMessageChannel.cs) +* Simple interpolation - [Assets/Scripts/Utils/PositionLerper.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Utils/PositionLerper.cs) +* Network Object Pooling - [Assets/Scripts/Infrastructure/NetworkObjectPool.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Infrastructure/NetworkObjectPool.cs) +* NetworkGuid - [Assets/Scripts/Infrastructure/NetworkGuid.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Infrastructure/NetworkGuid.cs) +* Netcode hooks - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetcodeHooks.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetcodeHooks.cs) +* Spawner for in-scene objects - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs) +* Session manager for reconnection - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs) +* Relay utils - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs) +* Client authority - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs) +* Scene utils with synced loading screens - [Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement) +* RNSM custom config - [Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/CustomNetStatsMonitorConfiguration.asset](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/CustomNetStatsMonitorConfiguration.asset) +* NetworkSimulator usage through UI - [Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs ](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs) +* ParrelSync - [Packages/manifest.json](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/manifest.json) ### Troubleshooting @@ -236,7 +236,7 @@ Boss Room includes the following tools and utilities: ### Licence -Boss Room is licenced under the Unity Companion Licence. See [LICENSE.md](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/LICENSE.md) for more legal information. +Boss Room is licenced under the Unity Companion Licence. See [LICENSE.md](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/LICENSE.md) for more legal information. Visit the following links to learn more about Unity Netcode and Boss Room. @@ -248,30 +248,4 @@ Visit the following links to learn more about Unity Netcode and Boss Room. ### Other samples -The [Bitesize Samples](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize) repository is currently being expanded and has a collection of smaller samples and games showcasing sub-features of Netcode for GameObjects. You can review these samples with documentation to better understand our APIs and features. - -### Contributing - -Please check out [CONTRIBUTING.md](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0p/CONTRIBUTING.md) for full guidelines on submitting issues and PRs to Boss Room. - -Our projects use the `git-flow` branching strategy: - -* The `develop` branch has all active development. -* The `main` branch has release versions. - -To get the project on your machine, you need to clone the repository from GitHub using the following command-line command: - -```bash -git clone https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git -``` - -> [!NOTE] -> You should have [Git LFS](https://git-lfs.github.com/) installed on your local machine. - -Please check out [CONTRIBUTING.md](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/CONTRIBUTING.md) for guidelines on submitting issues and PRs to Boss Room! - -### Feedback form - -Thank you for cloning Boss Room and taking a look at the project. To help us improve and build better samples in the future, please consider submitting feedback about your experiences with Boss Room. It'll only take a couple of minutes. Thanks! - -[Enter the Boss Room Feedback Form](https://unitytech.typeform.com/bossroom) +The [Bitesize Samples](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize) repository is currently being expanded and has a collection of smaller samples and games showcasing sub-features of Netcode for GameObjects. You can review these samples with documentation to better understand our APIs and features. \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/networkobject-parenting.md b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/networkobject-parenting.md new file mode 100644 index 0000000000..b6c40567b1 --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/networkobject-parenting.md @@ -0,0 +1,20 @@ +# NetworkObject parenting inside Boss Room + +:::note +Required reading: [NetworkObject Parenting](../../advanced-topics/networkobject-parenting.md) +::: + +Before detailing Boss Room's approach to NetworkObject parenting, it's important to highlight a limitation of Netcode: A dynamically-spawned NetworkObject **can't** contain another NetworkObject in its hierarchy. If you spawn such a NetworkObject, you can't spawn children `NetworkObjects`. You can only add children NetworkObject components to a NetworkObject that is part of a scene. + +Boss Room leverages NetworkObject parenting through the server-driven `PickUp` action (see [`PickUpAction.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/PickUpAction.cs)), where a character has the ability to pick up a specially-tagged, in-scene placed NetworkObject (see [`PickUpPot` prefab](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Prefabs/Game/PickUpPot.prefab)]. + +At its root, `PickUpPot` has a NetworkObject, a `NetworkTransform`, and a `PositionConstraint` component. `AutoObjectParentSync` is enabled on its `NetworkTransform` (as is by default) so that: + +1. The NetworkObject can verify server-side if parenting a Heavy object to another NetworkObject is allowed. +2. The NetworkObject can notify us when the parent has successfully been modified server-side. + +To accommodate the limitation highlighted at the beginning of this document, Boss Room leverages the `PositionConstraint` component to simulate an object following a character's position. + +A special hand bone has been added to our Character's avatar. Upon a character's successful parenting attempt, this special bone is set as the `PickUpPot`'s `PositonConstraint` target. So while the `PickUpPot` is technically parented to a player, the `PositionConstraint` component allows the `PickUpPot` to follow a bone's position, presenting the **illusion** that the `PickUpPot` is parented to the player's hand bone itself. + +Once the `PickUpPot` is parented, local space simulation is enabled on its [`NetworkTransform` component](../../components/networktransform.md). diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/networkrigidbody.md b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/networkrigidbody.md new file mode 100644 index 0000000000..dcb0339cb9 --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/networkrigidbody.md @@ -0,0 +1,9 @@ +# NetworkRigidbody inside Boss Room + +:::note +Required reading: [Physics](../..//advanced-topics/physics.md) +::: + +Boss Room leverages `NetworkRigidbody` to simulate physics-based projectiles. See the Vandal Imp's tossed projectile, the [`ImpTossedItem` prefab](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Prefabs/Game/ImpTossedItem.prefab). At its root, this Prefab has a NetworkObject, a `NetworkTransform`, a `Rigidbody`, and a `NetworkRigidbody` component. Refer to [`TossAction.cs`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Scripts/Gameplay/Action/ConcreteActions/TossAction.cs) for more implementation details. + +An important note: You must do any modifications to a `Rigidbody` that involve Physics (modifying velocity, applying forces, applying torque, and the like) **after** the NetworkObject spawns since `NetworkRigidbody` forces the `Rigidbody`'s `isKinematic` flag to be true on `Awake()`. Once spawned, this flag is modified depending on the ownership status of the NetworkObject. diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/optimizing-bossroom.md b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/optimizing-bossroom.md similarity index 98% rename from com.unity.netcode.gameobjects/Documentation~/learn/bossroom/optimizing-bossroom.md rename to com.unity.netcode.gameobjects/Documentation~/samples/bossroom/optimizing-bossroom.md index edb037e2bb..d0dc30537c 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/bossroom/optimizing-bossroom.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/optimizing-bossroom.md @@ -91,8 +91,9 @@ The impact of surpassing the Max Packet Queue Size threshold varies depending on Setting the Max Packet Queue Size parameter too low can introduce some [jitter](../../learn/lagandpacketloss.md) during frames where the number of packets sent or received is too high. On the other hand, setting the Max Packet Queue Size parameter too high would use more memory than necessary. -> [!NOTE] -> Each unit in the Max Packet Queue Size parameter uses roughly 4 KB of memory. This value is based on twice the maximum size of a packet, which Unity Transport defines internally (it isn't exposed to Netcode users since this parameter governs the sizes of both the send and receive queues). +:::note +**Note**: Each unit in the Max Packet Queue Size parameter uses roughly 4 KB of memory. This value is based on twice the maximum size of a packet, which Unity Transport defines internally (it isn't exposed to Netcode users since this parameter governs the sizes of both the send and receive queues). +::: The Boss Room sample uses a Max Packet Queue Size property value of 256. The reasoning behind choosing 256 is specific to how Boss Room uses Unity Transport. diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/spawn-networkobjects.md b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/spawn-networkobjects.md new file mode 100644 index 0000000000..3ca75ddbad --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bossroom/spawn-networkobjects.md @@ -0,0 +1,24 @@ +# Spawn NetworkObjects in Boss Room + +:::note +Required reading: [Object Spawning](../../basics/object-spawning.md). +::: + +This document serves as a walkthrough of Boss Room's approach to solving the following issue: Late-joining clients entering networked sessions encountering zombie `NetworkObjects`. Zombie `NetworkObjects` represent `NetworkObjects` that are instantiated for a client due to scene loads but aren't despawned or destroyed by Netcode. + +This is a particular Netcode limitation of NetworkObject spawning: `NetworkObjects` that belong to a scene object should not be destroyed until its scene has been unloaded through Netcode's scene management. + +The scenario in question: + +* A host loads a scene and destroys a NetworkObject that belonged to that scene. +* A client joins the host's session and loads the additive scene. This operation loads **all** the `GameObjects` included in the additive scene. The NetworkObject that was destroyed on the server won't be destroyed on the client's machine. + +This scenario manifested inside Boss Room, whereby late-joining clients joining a game session encountered zombie NetworkObjects that were not destroyed over the network. + +Additive scenes now contain Prefab instances of a custom spawner, [`NetworkObjectSpawner`](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs) to accommodate this visual inconsistency. + +Compositionally, these additive scenes now only contain the following: + +* Prefab instances of level geometry. +* Prefab instances of NetworkObjects that will **not** be despawned nor destroyed for the scene's lifetime. Examples include [BreakablePot](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Prefabs/Game/BreakablePot.prefab) and [BreakableCrystal](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/Prefabs/Game/BreakableCrystal.prefab). +* Prefab instances of `NetworkObjectSpawner`, which spawn NetworkObjects that **may** be destroyed or despawned during the scene's lifetime. Examples include [Imp](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/GameData/Character/Imp/Imp.asset), [VandalImp](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/GameData/Character/VandalImp/VandalImp.asset), and [ImpBoss](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/main/Assets/GameData/Character/ImpBoss/ImpBoss.asset). diff --git a/com.unity.netcode.gameobjects/Documentation~/tutorials/helloworld.md b/com.unity.netcode.gameobjects/Documentation~/tutorials/helloworld.md index 5a60ff8690..1e9689a44b 100644 --- a/com.unity.netcode.gameobjects/Documentation~/tutorials/helloworld.md +++ b/com.unity.netcode.gameobjects/Documentation~/tutorials/helloworld.md @@ -271,6 +271,6 @@ See the following content to continue your journey using Netcode: * Build on the Hello World project to continue learning about different features of Netcode with the [Golden Path series](goldenpath_series/gp_intro.md). * Check out the educational samples to further explore Netcode and its abilities: * [Boss Room](../learn/bossroom/getting-started-boss-room.md) - * [2D Spaceshooter Bitesize Sample](../learn/bitesize/bitesize-spaceshooter.md) - * [Invaders Bitesize Sample](../learn/bitesize/bitesize-invaders.md) - * [Client-Driven Bitesize Sample](../learn/bitesize/bitesize-clientdriven.md) + * [2D Spaceshooter Bitesize Sample](../samples/bitesize/bitesize-spaceshooter.md) + * [Invaders Bitesize Sample](../samples/bitesize/bitesize-invaders.md) + * [Client-Driven Bitesize Sample](../samples/bitesize/bitesize-clientdriven.md) From 2ac53651cec668048b1815ab369c2d0ae8bb0bd5 Mon Sep 17 00:00:00 2001 From: Amy Reeve Date: Tue, 8 Jul 2025 18:38:41 +0100 Subject: [PATCH 2/3] Applying docs fixes for patch release --- .../Documentation~/TableOfContents.md | 1 + .../advanced-topics/bufferserializer.md | 2 +- .../advanced-topics/client-anticipation.md | 2 +- .../advanced-topics/custom-serialization.md | 2 +- .../fastbufferwriter-fastbufferreader.md | 2 +- .../advanced-topics/message-system/rpc.md | 1 - .../Documentation~/da-quickstart.md | 4 +- .../learn/listenserverhostarchitecture.md | 6 +-- .../samples/bitesize/bitesize-landing.md | 3 +- .../samples/bitesize/bitesize-socialhub.md | 46 +++++++++++++++++++ .../terms-concepts/distributed-authority.md | 4 +- .../Documentation~/tutorials/helloworld.md | 5 +- 12 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-socialhub.md diff --git a/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md b/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md index 04eb77034e..934ba90111 100644 --- a/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md +++ b/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md @@ -108,3 +108,4 @@ * [Bitesize space shooter](samples/bitesize/bitesize-spaceshooter.md) * [Bitesize client driven](samples/bitesize/bitesize-clientdriven.md) * [Bitesize dynamic prefabs](samples/bitesize/bitesize-dynamicPrefabs.md) + * [Bitesize social hub](samples/bitesize/bitesize-socialhub.md) diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/bufferserializer.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/bufferserializer.md index 15d269b34a..22375bccf5 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/bufferserializer.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/bufferserializer.md @@ -1,6 +1,6 @@ # BufferSerializer -`BufferSerializer` is the bi-directional serializer primarily used for serializing within [`INetworkSerializable`](inetworkserializable.md) types. It wraps [`FastBufferWriter` and `FastBufferReader`](fastbufferwriter-fastbufferreader.md) to provide high performance serialization, but has a couple of differences to make it more user-friendly: +`BufferSerializer` is the bi-directional serializer primarily used for serializing within [`INetworkSerializable`](serialization/inetworkserializable.md) types. It wraps [`FastBufferWriter` and `FastBufferReader`](fastbufferwriter-fastbufferreader.md) to provide high performance serialization, but has a couple of differences to make it more user-friendly: - Rather than writing separate methods for serializing and deserializing, `BufferSerializer` allows writing a single method that can handle both operations, which reduces the possibility of a mismatch between the two - `BufferSerializer` does bound checking on every read and write by default, making it easier to avoid mistakes around manual bounds checking required by `FastBufferWriter` and `FastBufferReader` diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/client-anticipation.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/client-anticipation.md index 1d2720bb70..828d5ea3ab 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/client-anticipation.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/client-anticipation.md @@ -6,7 +6,7 @@ Client anticipation uses `AnticipatedNetworkVariable` and `AnticipatedNetwork ## Overview -Games with a server-authoritative architecture often face the problem of making the game feel responsive despite [latency](../learn/ladandpacketloss.md). For example, when a user wants to change the color of an object from green to blue they click a button in the UI, an RPC is sent to the server, and the server changes the object to blue. From the client's perspective, the object doesn't change to blue until the server responds to that message, resulting in a perceived delay for the user. +Games with a server-authoritative architecture often face the problem of making the game feel responsive despite [latency](../learn/lagandpacketloss.md). For example, when a user wants to change the color of an object from green to blue they click a button in the UI, an RPC is sent to the server, and the server changes the object to blue. From the client's perspective, the object doesn't change to blue until the server responds to that message, resulting in a perceived delay for the user. ![](../images/sequence_diagrams/Anticipation/ServerAuthoritative.png) diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/custom-serialization.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/custom-serialization.md index 1f754d59c1..7a04e2f123 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/custom-serialization.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/custom-serialization.md @@ -39,7 +39,7 @@ public static class SerializationExtensions The code generation for RPCs will automatically pick up and use these functions, and they'll become available via `FastBufferWriter` and `FastBufferReader` directly. -You can also optionally use the same method to add support for `BufferSerializer.SerializeValue()`, if you wish, which will make this type readily available within [`INetworkSerializable`](/advanced-topics/serialization/inetworkserializable.md) types: +You can also optionally use the same method to add support for `BufferSerializer.SerializeValue()`, if you wish, which will make this type readily available within [`INetworkSerializable`](serialization/inetworkserializable.md) types: ```csharp // The class name doesn't matter here. diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/fastbufferwriter-fastbufferreader.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/fastbufferwriter-fastbufferreader.md index 0d514dfb2b..1ac9b0f9d3 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/fastbufferwriter-fastbufferreader.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/fastbufferwriter-fastbufferreader.md @@ -121,7 +121,7 @@ For performance reasons, by default, `FastBufferReader` and `FastBufferWriter` * > **In editor mode and development builds**, calling these functions records a watermark point, and any attempt to read or write past the watermark point will throw an exception. This ensures these functions are used properly, while avoiding the performance cost of per-operation checking in production builds. In production builds, attempting to read or write past the end of the buffer will cause undefined behavior, likely program instability and/or crashes. -For convenience, every `WriteValue()` and `ReadValue()` method has an equivalent `WriteValueSafe()` and `ReadValueSafe()` that does bounds checking for you, throwing `OverflowException` if the boundary is exceeded. Additionally, some methods, such as arrays (where the amount of data being read can't be known until the size value is read) and [`INetworkSerializable`](inetworkserializable.md) values (where the size can't be predicted outside the implementation) will always do bounds checking internally. +For convenience, every `WriteValue()` and `ReadValue()` method has an equivalent `WriteValueSafe()` and `ReadValueSafe()` that does bounds checking for you, throwing `OverflowException` if the boundary is exceeded. Additionally, some methods, such as arrays (where the amount of data being read can't be known until the size value is read) and [`INetworkSerializable`](serialization/inetworkserializable.md) values (where the size can't be predicted outside the implementation) will always do bounds checking internally. ## Bitwise Reading and Writing diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/message-system/rpc.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/message-system/rpc.md index e2d4916a53..a8569b4697 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/message-system/rpc.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/message-system/rpc.md @@ -218,4 +218,3 @@ There are a few other parameters that can be passed to either the `Rpc` attribut ## Additional resources * [RPC parameters](rpc-params.md) -* [Boss Room RPC Examples](../../learn/bossroom/bossroom-actions.md) diff --git a/com.unity.netcode.gameobjects/Documentation~/da-quickstart.md b/com.unity.netcode.gameobjects/Documentation~/da-quickstart.md index 9e0a48e542..6c698b1c65 100644 --- a/com.unity.netcode.gameobjects/Documentation~/da-quickstart.md +++ b/com.unity.netcode.gameobjects/Documentation~/da-quickstart.md @@ -4,5 +4,5 @@ Manage latency and performance in your Netcode for GameObjects project. | **Topic** | **Description** | | :------------------------------ | :------------------------------- | -| **[Distributed authority general quickstart](learn/distributed-authority-quick-start.md)** | Use this guide to learn how to create your first [distributed authority](../terms-concepts/distributed-authority.md) Netcode for GameObjects project. | -| **[Distributed authority WebGL quickstart](learn/distributed-authority-webgl.md)** | Use this guide to learn how to create your first [distributed authority](../terms-concepts/distributed-authority.md) Netcode for GameObjects WebGL project. | \ No newline at end of file +| **[Distributed authority general quickstart](learn/distributed-authority-quick-start.md)** | Use this guide to learn how to create your first [distributed authority](terms-concepts/distributed-authority.md) Netcode for GameObjects project. | +| **[Distributed authority WebGL quickstart](learn/distributed-authority-webgl.md)** | Use this guide to learn how to create your first [distributed authority](terms-concepts/distributed-authority.md) Netcode for GameObjects WebGL project. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/listenserverhostarchitecture.md b/com.unity.netcode.gameobjects/Documentation~/learn/listenserverhostarchitecture.md index 154fcd2e2c..e32e3858c8 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/listenserverhostarchitecture.md +++ b/com.unity.netcode.gameobjects/Documentation~/learn/listenserverhostarchitecture.md @@ -67,9 +67,9 @@ A relay server costs money, and the round trip times for packet exchange may be 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. Ways to NAT punch: -* Session Traversal Utilities for NAT [STUN](../reference/glossary/network-terms.md#session-traversal-utilities-for-nat-stun) -* Interactive Connectivity Establishment [ICE](../reference/glossary/network-terms.md#interactive-connectivity-establishment-ice) -* User Datagram Protocol [(UDP) hole punching](../reference/glossary/network-terms.md#udp-hole-punching) +* Session Traversal Utilities for NAT STUN +* Interactive Connectivity Establishment ICE +* User Datagram Protocol (UDP) hole punching Because of its high rate of failure, NAT punch-through is typically only used with a relay fallback. diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-landing.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-landing.md index b75e2d73f0..880fbb821e 100644 --- a/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-landing.md +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-landing.md @@ -8,4 +8,5 @@ The Bite Size samples are small, focused examples that demonstrate specific feat | **[Bitesize introduction](bitesize-introduction.md)** | The Bitesize Samples repository provides a series of sample code as modules to use in your games and better understand Netcode for GameObjects. | | **[Bitesize space shooter](bitesize-spaceshooter.md)** | Learn more about physics movement and status effects using Netcode for GameObjects (Netcode) NetworkVariables and ObjectPooling. | | **[Bitesize client driven](bitesize-clientdriven.md)** | Learn more about Client driven movements, networked physics, spawning vs statically placed objects, object reparenting. | -| **[Bitesize dynamic prefabs](bitesize-dynamicPrefabs.md)** | Learn more about the dynamic Prefab system, which allows you to add new spawnable Prefabs at runtime. | \ No newline at end of file +| **[Bitesize dynamic prefabs](bitesize-dynamicPrefabs.md)** | Learn more about the dynamic Prefab system, which allows you to add new spawnable Prefabs at runtime. | +| **[Bitesize social hub](bitesize-socialhub.md)** | The Distributed Authority Social Hub Sample is a project that demonstrates Distributed Authority's features and helps you integrate Distributed Authority into your own game projects. | \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-socialhub.md b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-socialhub.md new file mode 100644 index 0000000000..6adf276469 --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/samples/bitesize/bitesize-socialhub.md @@ -0,0 +1,46 @@ +# Distributed Authority Social Hub sample + +The [Distributed Authority Social Hub Sample](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/tree/main/Basic/DistributedAuthoritySocialHub) is a project that demonstrates Distributed Authority's features and helps you integrate Distributed Authority into your own game projects. + +Within Social Hub, you can explore Distributed Authority in a sandbox-like environment. You can: + +- Automatically redistribute ownership of NetworkObjects across connected clients +- Experience responsive gameplay through client-side NetworkObject spawning and deferred NetworkObject despawning +- Transfer ownership of NetworkObjects with variable ownership flags +- Host migration of a networked game session + +## Prerequisites + +Social Hub uses services from Unity Gaming Services to facilitate connectivity between players. To use these services inside your project, you must: + +1. [Create an organization](https://support.unity.com/hc/en-us/articles/208592876-How-do-I-create-a-new-Unity-organization) inside the Unity Dashboard. +2. Register your Unity project with that organization's cloud ID. + +## The Bootstrap scene + +This is the entry point to the sample. After the Bootstrap scene loads, the MainMenu scene appears. + +**Note**: Be sure you have registered the project with a cloud ID. + +## The MainMenu scene + +To create or join an existing game: + +1. Enter a player name and a session name. +2. Select **Start**. + +A successful load indicates that you have correctly registered your project with a cloud ID. + +## The HubScene_TownMarket scene + +This a sandbox-like environment that supports 64 players. The control model is WASD controls. Move around the level with client-authority, and use **E** to interact with crates and pots. These are NetworkObjects that you can pick up, drop, and throw. Attach one NetworkObject to another with an animated rig through the use of FixedJoints. As a client picks up a NetworkObject, authority of that NetworkObject transfers to that client. + +A client has authority over its player NetworkObject. Therefore, the movement, animations, and interactions that a client performs are client-authoritative. + +This sample inherently supports host migration out of the box. Load multiple clients, and witness the automatic distribution of ownership of NetworkObjects when the original session owner leaves the session. + +## Additional resources + +- Get help and ask questions on [Multiplayer Discussions](https://discussions.unity.com/lists/multiplayer). +- Join the community of Multiplayer creators on the [Multiplayer Networking Discord](https://discord.gg/unity-multiplayer-network). +- [Request a feature or report a bug](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/issues/new/choose). diff --git a/com.unity.netcode.gameobjects/Documentation~/terms-concepts/distributed-authority.md b/com.unity.netcode.gameobjects/Documentation~/terms-concepts/distributed-authority.md index 4207f88e13..b45bf99822 100644 --- a/com.unity.netcode.gameobjects/Documentation~/terms-concepts/distributed-authority.md +++ b/com.unity.netcode.gameobjects/Documentation~/terms-concepts/distributed-authority.md @@ -4,7 +4,7 @@ The [distributed authority network topology](network-topologies.md#distributed-authority) is one possible [network topology](network-topologies.md) available within Netcode for GameObjects. Distributed authority games use the [distributed authority model](authority.md#distributed-authority). -The traditional [client-server network topology](network-topologies.md/#client-server) has a dedicated game instance running the game simulation. This means all state changes must be communicated to the server and then the server communicates those updates to all other connected clients. This design works well when using a powerful dedicated game server, however significant latencies are added when communicating state changes with a [listen server architecture](../learn/listenserverhostarchitecture.md). +The traditional [client-server network topology](network-topologies.md#client-server) has a dedicated game instance running the game simulation. This means all state changes must be communicated to the server and then the server communicates those updates to all other connected clients. This design works well when using a powerful dedicated game server, however significant latencies are added when communicating state changes with a [listen server architecture](../learn/listenserverhostarchitecture.md). > [!NOTE] > The distributed authority service provided by the [Multiplayer Services package](https://docs.unity.com/ugs/en-us/manual/mps-sdk/manual) offers a free tier for bandwidth and connectivity hours, allowing you to develop and test without immediate cost. Refer to the [Unity Gaming Services pricing page](https://unity.com/products/gaming-services/pricing) for complete details. @@ -31,4 +31,4 @@ For more information about how distributed authority works in Netcode for GameOb - [Race conditions](../basics/race-conditions.md) - [Spawning synchronization](../basics/spawning-synchronization.md) - [Deferred despawning](../basics/deferred-despawning.md) -- [Distributed Authority Social Hub sample](../learn/bitesize/bitesize-socialhub.md) +- [Distributed Authority Social Hub sample](../samples/bitesize/bitesize-socialhub.md) diff --git a/com.unity.netcode.gameobjects/Documentation~/tutorials/helloworld.md b/com.unity.netcode.gameobjects/Documentation~/tutorials/helloworld.md index 1e9689a44b..69289e04bf 100644 --- a/com.unity.netcode.gameobjects/Documentation~/tutorials/helloworld.md +++ b/com.unity.netcode.gameobjects/Documentation~/tutorials/helloworld.md @@ -2,7 +2,7 @@ A "Hello World" program is a computer program that outputs or displays the message "Hello, World!". Normally it's the first program written by people learning to code. it's also used as a sanity test to make sure that a computer language is correctly installed and that the operator understands how to use it. -This "Hello World" tutorial walks you through creating a project, installing Netcode for GameObjects (Netcode), and creating the basic components for your first networked game. it's also the base for the [Golden Path series](goldenpath_series/gp_intro.md). +This "Hello World" tutorial walks you through creating a project, installing Netcode for GameObjects (Netcode), and creating the basic components for your first networked game. ## Create a new project in Unity @@ -268,9 +268,8 @@ You can also use the command line helper to launch a server and one or more clie See the following content to continue your journey using Netcode: -* Build on the Hello World project to continue learning about different features of Netcode with the [Golden Path series](goldenpath_series/gp_intro.md). * Check out the educational samples to further explore Netcode and its abilities: - * [Boss Room](../learn/bossroom/getting-started-boss-room.md) + * [Boss Room](../samples/bossroom/getting-started-boss-room.md) * [2D Spaceshooter Bitesize Sample](../samples/bitesize/bitesize-spaceshooter.md) * [Invaders Bitesize Sample](../samples/bitesize/bitesize-invaders.md) * [Client-Driven Bitesize Sample](../samples/bitesize/bitesize-clientdriven.md) From ab5941da9eabae4388f11249484782bfe156ef7e Mon Sep 17 00:00:00 2001 From: Amy Reeve Date: Tue, 15 Jul 2025 11:18:37 +0100 Subject: [PATCH 3/3] Removing external code references --- .../Documentation~/TableOfContents.md | 10 +--------- .../advanced-topics/object-pooling.md | 4 ++++ .../advanced-topics/session-management.md | 4 ++++ .../Documentation~/basics/maxnumberplayers.md | 7 ++++++- .../Documentation~/learn/rpcvnetvar.md | 17 ++++++++++++----- .../Documentation~/removed-tableofcontents.md | 16 ++++++++++++++++ 6 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 com.unity.netcode.gameobjects/Documentation~/removed-tableofcontents.md diff --git a/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md b/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md index 934ba90111..f784cc5148 100644 --- a/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md +++ b/com.unity.netcode.gameobjects/Documentation~/TableOfContents.md @@ -55,7 +55,6 @@ * [Reliability](advanced-topics/message-system/reliability.md) * [RPC params](advanced-topics/message-system/rpc-params.md) * [RPC vs NetworkVariables](learn/rpcvnetvar.md) - * [RPC and NetworkVariable examples](learn/rpcnetvarexamples.md) * [RPC compatibility](advanced-topics/message-system/rpc-compatibility.md) * [Custom messages](advanced-topics/message-system/custom-messages.md) * [Connection events](advanced-topics/connection-events.md) @@ -101,11 +100,4 @@ * [NetworkObject parenting](samples/bossroom/networkobject-parenting.md) * [Optimizing Boss Room](samples/bossroom/optimizing-bossroom.md) * [NetworkRigidbody](samples/bossroom/networkrigidbody.md) - * [Spawn NetworkObjects](samples/bossroom/spawn-networkobjects.md) - * [Bitesize samples](samples/bitesize/bitesize-landing.md) - * [Bitesize use cases](samples/bitesize/bitesize-usecases.md) - * [Bitesize introduction](samples/bitesize/bitesize-introduction.md) - * [Bitesize space shooter](samples/bitesize/bitesize-spaceshooter.md) - * [Bitesize client driven](samples/bitesize/bitesize-clientdriven.md) - * [Bitesize dynamic prefabs](samples/bitesize/bitesize-dynamicPrefabs.md) - * [Bitesize social hub](samples/bitesize/bitesize-socialhub.md) + * [Spawn NetworkObjects](samples/bossroom/spawn-networkobjects.md) \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/object-pooling.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/object-pooling.md index 2234e724fb..32e7add573 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/object-pooling.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/object-pooling.md @@ -16,6 +16,8 @@ You can register your own spawn handlers by including the `INetworkPrefabInstanc ``` Netcode will use the `Instantiate` and `Destroy` methods in place of default spawn handlers for the `NetworkObject` used during spawning and despawning. Because the message to instantiate a new `NetworkObject` originates from a Host or Server, both won't have the Instantiate method invoked. All clients (excluding a Host) will have the instantiate method invoked if the `INetworkPrefabInstanceHandler` implementation is registered with `NetworkPrefabHandler` (`NetworkManager.PrefabHandler`) and a Host or Server spawns the registered/associated `NetworkObject`. + \ No newline at end of file diff --git a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/session-management.md b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/session-management.md index f9944f8fb8..6f3e0f0d19 100644 --- a/com.unity.netcode.gameobjects/Documentation~/advanced-topics/session-management.md +++ b/com.unity.netcode.gameobjects/Documentation~/advanced-topics/session-management.md @@ -23,6 +23,8 @@ The best way to reconnect players depends on your game. For example, if you use In cases where we don't use the Player Object approach and instead manually attribute client ownership to `NetworkObject`(s), we can keep the objects that a player owns when they disconnect, and set the reconnected player as their new owner. To accomplish this, the only data we would need to keep would be the mapping between those objects and their owning player's identifier, then when a player reconnects we can use this mapping to set them as the new owner. This mapping can be as simple as a dictionary mapping the player identifier with the `NetworkObjectId`(s) of the `NetworkObject`(s) they own. Then, in the `OnClientConnectedCallback` from the `NetworkManager`, the server can set the ownership of these objects. + diff --git a/com.unity.netcode.gameobjects/Documentation~/basics/maxnumberplayers.md b/com.unity.netcode.gameobjects/Documentation~/basics/maxnumberplayers.md index bceeb8ec1e..fa5ca5add4 100644 --- a/com.unity.netcode.gameobjects/Documentation~/basics/maxnumberplayers.md +++ b/com.unity.netcode.gameobjects/Documentation~/basics/maxnumberplayers.md @@ -2,16 +2,18 @@ Netcode for GameObjects provides a way to customize the [connection approval process](connection-approval.md) that can reject incoming connections based on any number of user-specific reasons. + The code below shows an example of an over-capacity check that would prevent more than a certain pre-defined number of players from connecting. - ```csharp if( m_Portal.NetManager.ConnectedClientsIds.Count >= CharSelectData.k_MaxLobbyPlayers ) { @@ -21,6 +23,9 @@ if( m_Portal.NetManager.ConnectedClientsIds.Count >= CharSelectData.k_MaxLobbyPl > [!NOTE]​ > In connection approval delegate, Netcode for GameObjects doesn't support sending anything more than a Boolean back. + + When using Relay, ensure the maximum number of peer connections allowed by the host satisfies the logic implemented in the connection approval delegate. diff --git a/com.unity.netcode.gameobjects/Documentation~/learn/rpcvnetvar.md b/com.unity.netcode.gameobjects/Documentation~/learn/rpcvnetvar.md index 6a95d6bce0..0713cbab28 100644 --- a/com.unity.netcode.gameobjects/Documentation~/learn/rpcvnetvar.md +++ b/com.unity.netcode.gameobjects/Documentation~/learn/rpcvnetvar.md @@ -10,13 +10,15 @@ Netcode for GameObjects (Netcode) has two main ways of syncing information betwe A quick way to choose which to use is to ask yourself: "Should a player joining mid-game get that information?" -![Network Variables allow to seamlessly catch up late joining clients by sending the current state as soon as the tick happens.](../../images/sequence_diagrams/NetworkVariable/NetworkVariables_LateJoinClient.png) +![Network Variables allow to seamlessly catch up late joining clients by sending the current state as soon as the tick happens.](../images/sequence_diagrams/NetworkVariable/NetworkVariables_LateJoinClient.png) Using the Boss Room's door as an example. A player's client needs to receive the information that the door is open to play the right animations. If we sent an RPC to all clients, then all players connecting mid-game after that RPC is sent will miss that information and have the wrong visual on their clients. -![Sending state with RPCs won't be transmitted to late joining clients.](../../images/sequence_diagrams/NetworkVariableVSRPCs/RPCsLateJoin.png) +![Sending state with RPCs won't be transmitted to late joining clients.](../images/sequence_diagrams/NetworkVariableVSRPCs/RPCsLateJoin.png) + + + `NetworkVariable`s are eventually consistent. This means not all value changes will be synced, contrary to RPCs, where five calls to an RPC will produce five RPC sends on the network. -![Network Variables can be updated multiple times between ticks, but only the latest will be synced to other peers.](../../images/sequence_diagrams/NetworkVariable/NetworkVariables.png) +![Network Variables can be updated multiple times between ticks, but only the latest will be synced to other peers.](../images/sequence_diagrams/NetworkVariable/NetworkVariables.png) `NetworkVariable`s will save on bandwidth for you, making sure to only send values when the data has changed. However, if you want all value changes, RPCs might be best. @@ -40,6 +44,8 @@ If you have a temporary event like an explosion, you don't need a replicated sta An explosion can use an RPC for the event, but the effect of the explosion should be using `NetworkVariable`s (for example player's knockback and health decrease). A newly connected player doesn't care about an explosion that happened five seconds ago. They do care about the current health of the players around that explosion though. + If you want to make sure two variables are received at the same time, RPCs are great for this. If you change `NetworkVariables` "a" and "b", there is no guarantee they will both be received client side at the same time. -![Different Network Variables updated within the same tick aren't guaranteed to be delivered to the clients at the same time.](../../images/sequence_diagrams/NetworkVariable/NetVarDataUpdates.png) +![Different Network Variables updated within the same tick aren't guaranteed to be delivered to the clients at the same time.](../images/sequence_diagrams/NetworkVariable/NetVarDataUpdates.png) Sending them as two parameters in the same RPC ensures they will be received at the same time client side. -![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.](../../images/sequence_diagrams/NetworkVariableVSRPCs/ManagingNetVarData_RPCs.png) +![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.](../images/sequence_diagrams/NetworkVariableVSRPCs/ManagingNetVarData_RPCs.png) `NetworkVariable`s are great when you only care about the latest value. diff --git a/com.unity.netcode.gameobjects/Documentation~/removed-tableofcontents.md b/com.unity.netcode.gameobjects/Documentation~/removed-tableofcontents.md new file mode 100644 index 0000000000..e9eadb4428 --- /dev/null +++ b/com.unity.netcode.gameobjects/Documentation~/removed-tableofcontents.md @@ -0,0 +1,16 @@ + + + \ No newline at end of file