From bc0bbf5d3ce21ead10fbabc4997949f281666fbc Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Tue, 1 Nov 2022 14:13:06 -0400 Subject: [PATCH 01/12] fixing typo and broken link --- docs/tutorials/goldenpath_series/gp_module_one.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/goldenpath_series/gp_module_one.md b/docs/tutorials/goldenpath_series/gp_module_one.md index ef89c1c3d..ab0f61d84 100644 --- a/docs/tutorials/goldenpath_series/gp_module_one.md +++ b/docs/tutorials/goldenpath_series/gp_module_one.md @@ -35,7 +35,7 @@ This section adds some scripts to Hello World that contain the new features cove ### Adding the `HelloWorldPlayer.cs` script -1. Create a new script `HelloWorldPlayer`. +1. Create a new script called `HelloWorldPlayer`. 1. Open the `HelloWorldPlayer.cs` script. 1. Edit the `HelloWorldPlayer.cs` script to match the following. @@ -464,7 +464,7 @@ One build instance can create a host. Another client can join the host's game. B See the following content to continue your journey using Netcode: -* Build on the your growing Hello World project to continue learning about different features of Netcode with [Golden Path Two](goldenpath_two) +* Build on the your growing Hello World project to continue learning about different features of Netcode with [Golden Path Two](gp_module_two.md) * Check out the educational samples to further explore Netcode and its abilities: * [Boss Room](../../learn/bossroom/bossroom) * [2D Spaceshooter Bitesize Sample](../../learn/bitesize/bitesize-spaceshooter) From a0471291ab67c808325b29e25cf37760e388d55a Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Tue, 1 Nov 2022 14:13:42 -0400 Subject: [PATCH 02/12] clarifying the Testing Hello World section --- docs/tutorials/helloworld.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/tutorials/helloworld.md b/docs/tutorials/helloworld.md index 360483a6f..e36ce9bc3 100644 --- a/docs/tutorials/helloworld.md +++ b/docs/tutorials/helloworld.md @@ -290,16 +290,19 @@ import TabItem from '@theme/TabItem'; ## Testing Hello World -Now we will test to see if everything works as expected. +Now, to see if everything works as expected we can test starting a host in the editor. A host plays the role of a server and a client at the same time. 1. Click **Play**. -1. Click **Start Host** under **NetworkManager**. +1. Click the **Start Host** button in the **NetworkManager** GameObject's inspector. +1. You should now see your scene with your Player Prefab spawned. + +You can also use the command line helper to launch a server and one or more client that will connect to the server. You should then see the plane on the server, until the first client connects. Then, for each connected client, a new Player Prefab will be spawned. ## Next Steps 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](../tutorials/goldenpath_series/gp_intro.md). +* 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) From 54595dc9367cce872d6014bc7e5dbaf173748f27 Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Tue, 1 Nov 2022 15:57:17 -0400 Subject: [PATCH 03/12] Clarified the usage of OnNetworkSpawn in HelloWorldPlayer --- docs/tutorials/goldenpath_series/gp_module_one.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/docs/tutorials/goldenpath_series/gp_module_one.md b/docs/tutorials/goldenpath_series/gp_module_one.md index ab0f61d84..7ebc43b1a 100644 --- a/docs/tutorials/goldenpath_series/gp_module_one.md +++ b/docs/tutorials/goldenpath_series/gp_module_one.md @@ -306,13 +306,7 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.poc/tree/fea ``` -Any `MonoBehaviour` implementing `NetworkBehaviour` can override the Netcode method `OnNetworkSpawn()`. This method is fired when the `NetworkObject` gets spawned. We override `OnNetworkSpawn` since a client and a server will run different logic here. - -:::note -This can be overriden on any `NetworkBehaviour`. -::: - -On both client and server instances of this player, we call the `Move()` method, which will simply do the following. +In a networked game, server/host machines may need to run different functions to a networked player/client. (For example, in a server-authoritative game, the client would handle the player inputs but the movement would be done on the server). All of the instances of this script in the game, whether they're the host/server or a client, will call the `OnNetworkSpawn` method when the `NetworkObject` to which this script is attached has spawned, but only its owner will call the `Move` method. In the case of a Player Object, every client (or host) will have one instance spawned for them, for which they will be the owner. Calling this in `OnNetworkSpawn` makes sure that the NetworkObject has finished spawning so the check to see whether the player is a Server/Host or Client is valid. The `Move` method can then implement different logic depending on the answer (so that Servers do one thing, and Clients do another).
Click to show/hide the Code. From 572a15d00256e0fa69e4bfd97918093b17f66d3f Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Tue, 1 Nov 2022 16:05:55 -0400 Subject: [PATCH 04/12] clarified Adding Editor Modes section in GP1 --- docs/tutorials/goldenpath_series/gp_module_one.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/goldenpath_series/gp_module_one.md b/docs/tutorials/goldenpath_series/gp_module_one.md index 7ebc43b1a..da1923af4 100644 --- a/docs/tutorials/goldenpath_series/gp_module_one.md +++ b/docs/tutorials/goldenpath_series/gp_module_one.md @@ -182,7 +182,7 @@ namespace HelloWorld ## Adding Editor Modes to Hello World -Inside the `HelloWorldManager.cs` script, we define two methods which mimic the editor buttons inside of **NetworkManager** during Play mode. +In the HelloWorld project, you created a **NetworkManager** by adding the pre-created **NetworkManager** component. In Play Mode, the NetworkManager shows Editor buttons labeled `Start Host`, `Start Client`, and `Start Server` in its inspector. These call the `StartHost`, `StartClient` and `StartServer` methods of the **NetworkManager** respectively, to initiate a networking session. Inside the `HelloWorldManager.cs` script, we define two methods which mimic this functionality via UI buttons and status labels.
Click to show/hide the Code. @@ -208,7 +208,7 @@ Inside the `HelloWorldManager.cs` script, we define two methods which mimic the ```
-`NetworkManager` implements the singleton pattern as it declares its singleton named `Singleton`. This is defined when the `MonoBehaviour` is enabled. This component also contains very useful properties, such as `IsClient`, `IsServer`, and `IsLocalClient`. The first two dictate the connection state we have currently established that you will use shortly. +The `NetworkManager` instance can be accessed statically from any other scripts via its singleton named `Singleton`. This is defined when the `MonoBehaviour` is enabled. This component also contains very useful properties, such as `IsClient`, `IsServer`, and `IsLocalClient`. The first two dictate the connection state we have currently established that you will use shortly. We call these methods inside of `OnGUI()`. From 4b7d664536aa3d035a28be92c36530c1844b1007 Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Tue, 1 Nov 2022 16:10:42 -0400 Subject: [PATCH 05/12] clarified use of command line helper --- docs/tutorials/helloworld.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/helloworld.md b/docs/tutorials/helloworld.md index e36ce9bc3..b0c5e9d2a 100644 --- a/docs/tutorials/helloworld.md +++ b/docs/tutorials/helloworld.md @@ -89,7 +89,7 @@ When 'Enable Scene Management' is enabled for the NetworkManager (allowing the s ## Creating a command line helper -This command line helper launches our project outside Unity and can make testing builds easier. +This command line helper will allow us to launch builds with a command line argument that will start a networking session, either as a server, host, or client. This can make testing builds easier. 1. Right-click the **Assets** folder and create a new folder by hovering over **Create** and selecting **Folder**. Name it **Scripts**. 2. Create a script called `NetworkCommandLine` by right-clicking on your **Scripts** folder, hovering over **Create** and selecting **C# Script**. From d2eb9706a964d07596249da084479ba86fffdbd9 Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Tue, 1 Nov 2022 16:15:39 -0400 Subject: [PATCH 06/12] Adding high-level explanation of what NetworkManager and UTP are in HelloWorld tutorial, with links to detailed docs --- docs/tutorials/helloworld.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/helloworld.md b/docs/tutorials/helloworld.md index b0c5e9d2a..445659f62 100644 --- a/docs/tutorials/helloworld.md +++ b/docs/tutorials/helloworld.md @@ -30,7 +30,7 @@ In this section we will create the basic building blocks of a multiplayer game. ### Creating Network Manager and selecting the Transport -In this section we will add a Network Manager and add Unity Transport (UTP) to our project. +In this section we will add a Network Manager and add Unity Transport (UTP) to our project. The [NetworkManager](../components/networkmanager.md) is the component that contains all of your project's netcode related settings. UTP is the transport layer that Netcode will use for communication between the server and the clients. See [here](../advanced-topics/transports.md) for more. 1. Right-click in the **Hierarchy** tab of the main Unity Window. 1. Select **Create Empty**. From b58f304b5dca00cfa96c12f2c167ee551b75f5d9 Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Tue, 1 Nov 2022 16:35:19 -0400 Subject: [PATCH 07/12] restructured GP1 to have instructions to add script after description of why we add them --- .../goldenpath_series/gp_module_one.md | 144 +++++++++--------- 1 file changed, 68 insertions(+), 76 deletions(-) diff --git a/docs/tutorials/goldenpath_series/gp_module_one.md b/docs/tutorials/goldenpath_series/gp_module_one.md index da1923af4..4ecec3cc6 100644 --- a/docs/tutorials/goldenpath_series/gp_module_one.md +++ b/docs/tutorials/goldenpath_series/gp_module_one.md @@ -27,79 +27,15 @@ You should have completed the [Hello World project](../helloworld.md) before sta 1. Open Unity Hub. 1. Select `Hello World` from the list of projects displayed. -## Adding Scripts to Hello World - -This section adds some scripts to Hello World that contain the new features covered in the tutorial. -1. Click the **Assets** folder. -2. Open the **Scripts** folder. - -### Adding the `HelloWorldPlayer.cs` script - -1. Create a new script called `HelloWorldPlayer`. -1. Open the `HelloWorldPlayer.cs` script. -1. Edit the `HelloWorldPlayer.cs` script to match the following. - -
-Click to show/hide the Code. - -```csharp -using Unity.Netcode; -using UnityEngine; - -namespace HelloWorld -{ - public class HelloWorldPlayer : NetworkBehaviour - { - public NetworkVariable Position = new NetworkVariable(); - - public override void OnNetworkSpawn() - { - if (IsOwner) - { - Move(); - } - } - - public void Move() - { - if (NetworkManager.Singleton.IsServer) - { - var randomPosition = GetRandomPositionOnPlane(); - transform.position = randomPosition; - Position.Value = randomPosition; - } - else - { - SubmitPositionRequestServerRpc(); - } - } - - [ServerRpc] - void SubmitPositionRequestServerRpc(ServerRpcParams rpcParams = default) - { - Position.Value = GetRandomPositionOnPlane(); - } - - static Vector3 GetRandomPositionOnPlane() - { - return new Vector3(Random.Range(-3f, 3f), 1f, Random.Range(-3f, 3f)); - } - - void Update() - { - transform.position = Position.Value; - } - } -} -``` -
+## Adding Editor Modes to Hello World -### Adding the `HelloWorldManager.cs` script +In the HelloWorld project, you created a **NetworkManager** by adding the pre-created **NetworkManager** component. In Play Mode, the NetworkManager shows Editor buttons labeled `Start Host`, `Start Client`, and `Start Server` in its inspector. These call the `StartHost`, `StartClient` and `StartServer` methods of the **NetworkManager** respectively, to initiate a networking session. Inside the `HelloWorldManager.cs` script, we define two methods which mimic this functionality via UI buttons and status labels. 1. Create an empty `GameObject` rename it **HelloWorldManager**. -1. Create a script called `HelloWorldManager`. -1. Open the `HelloWorldManager.cs` script. -1. Edit the `HelloWorldManager.cs` script to match the following. +2. Open the **Scripts** Folder. +3. Create a script called `HelloWorldManager`. +4. Open the `HelloWorldManager.cs` script. +5. Edit the `HelloWorldManager.cs` script to match the following. :::tip You can copy the script from here and paste it into your file. @@ -180,10 +116,6 @@ namespace HelloWorld 1. Add the `HelloWorldManager` script component to the `HelloWorldManager` `GameObject`. -## Adding Editor Modes to Hello World - -In the HelloWorld project, you created a **NetworkManager** by adding the pre-created **NetworkManager** component. In Play Mode, the NetworkManager shows Editor buttons labeled `Start Host`, `Start Client`, and `Start Server` in its inspector. These call the `StartHost`, `StartClient` and `StartServer` methods of the **NetworkManager** respectively, to initiate a networking session. Inside the `HelloWorldManager.cs` script, we define two methods which mimic this functionality via UI buttons and status labels. -
Click to show/hide the Code. @@ -244,7 +176,67 @@ You will notice the introduction of a new method, `SubmitNewPosition()`. This is ## Adding basic movement to the Player object -The `HelloWorldPlayer.cs` script adds some basic movement to the Hello World player. +Here we will create a `HelloWorldPlayer.cs` script that adds some basic movement to the Hello World player. + +1. Open the **Scripts** Folder. +1. Create a new script called `HelloWorldPlayer`. +1. Open the `HelloWorldPlayer.cs` script. +1. Edit the `HelloWorldPlayer.cs` script to match the following. + +
+Click to show/hide the Code. + +```csharp +using Unity.Netcode; +using UnityEngine; + +namespace HelloWorld +{ + public class HelloWorldPlayer : NetworkBehaviour + { + public NetworkVariable Position = new NetworkVariable(); + + public override void OnNetworkSpawn() + { + if (IsOwner) + { + Move(); + } + } + + public void Move() + { + if (NetworkManager.Singleton.IsServer) + { + var randomPosition = GetRandomPositionOnPlane(); + transform.position = randomPosition; + Position.Value = randomPosition; + } + else + { + SubmitPositionRequestServerRpc(); + } + } + + [ServerRpc] + void SubmitPositionRequestServerRpc(ServerRpcParams rpcParams = default) + { + Position.Value = GetRandomPositionOnPlane(); + } + + static Vector3 GetRandomPositionOnPlane() + { + return new Vector3(Random.Range(-3f, 3f), 1f, Random.Range(-3f, 3f)); + } + + void Update() + { + transform.position = Position.Value; + } + } +} +``` +
1. Select the **Player** prefab. @@ -458,7 +450,7 @@ One build instance can create a host. Another client can join the host's game. B See the following content to continue your journey using Netcode: -* Build on the your growing Hello World project to continue learning about different features of Netcode with [Golden Path Two](gp_module_two.md) +* Build on the your growing Hello World project to continue learning about different features of Netcode with [Golden Path Two](goldenpath_two.md) * Check out the educational samples to further explore Netcode and its abilities: * [Boss Room](../../learn/bossroom/bossroom) * [2D Spaceshooter Bitesize Sample](../../learn/bitesize/bitesize-spaceshooter) From f570d18d9e9ac824fadd07f05a8783940c7c1e2f Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Tue, 1 Nov 2022 16:37:24 -0400 Subject: [PATCH 08/12] fixing broken links --- docs/tutorials/goldenpath_series/gp_module_two.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/goldenpath_series/gp_module_two.md b/docs/tutorials/goldenpath_series/gp_module_two.md index 10ad0233d..367bb3768 100644 --- a/docs/tutorials/goldenpath_series/gp_module_two.md +++ b/docs/tutorials/goldenpath_series/gp_module_two.md @@ -149,7 +149,7 @@ Now we check that the Network Transform functions correctly. 1. Select **File** > **Build and Run**. 1. Stop the player. -1. Launch the client and server together in a terminal as shown in [Testing the command line helper](#testing-the-command-line-helper). +1. Launch the client and server together in a terminal as shown in [Testing the command line helper](../helloworld.md#testing-the-command-line-helper). 1. After a brief delay, the client and server will spawn. 1. You should see the player capsule moving in a circle on both the client and the server. @@ -212,7 +212,7 @@ Now we will test that the client and server are both recieving the RPCs correctl 1. Select **File** > **Build and Run**. 1. Stop the player. -1. Launch the client and server together in a terminal as shown in [Testing the command line helper](#testing-the-command-line-helper). +1. Launch the client and server together in a terminal as shown in [Testing the command line helper](../helloworld.md#testing-the-command-line-helper). 1. After a brief delay, the client and server will spawn. 1. In the console, you should expect to see the client and server sending RPC messages to each other. 1. The client kicks off the exchange in its `Update` call the first time with a counter value of 0. From 9e04ba12a11216cda36c81cd3d5fa6b7e8c34e83 Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Wed, 2 Nov 2022 13:34:47 -0400 Subject: [PATCH 09/12] fixing broken link --- docs/tutorials/goldenpath_series/gp_module_one.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/goldenpath_series/gp_module_one.md b/docs/tutorials/goldenpath_series/gp_module_one.md index 4ecec3cc6..8ced0aa8a 100644 --- a/docs/tutorials/goldenpath_series/gp_module_one.md +++ b/docs/tutorials/goldenpath_series/gp_module_one.md @@ -450,7 +450,7 @@ One build instance can create a host. Another client can join the host's game. B See the following content to continue your journey using Netcode: -* Build on the your growing Hello World project to continue learning about different features of Netcode with [Golden Path Two](goldenpath_two.md) +* Build on the your growing Hello World project to continue learning about different features of Netcode with [Golden Path Two](goldenpath_two) * Check out the educational samples to further explore Netcode and its abilities: * [Boss Room](../../learn/bossroom/bossroom) * [2D Spaceshooter Bitesize Sample](../../learn/bitesize/bitesize-spaceshooter) From 0d167c74ef6d747930860eabcf5e3bb4719ed7d2 Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Wed, 2 Nov 2022 13:42:56 -0400 Subject: [PATCH 10/12] adding links to gp_intro --- docs/tutorials/goldenpath_series/gp_intro.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/goldenpath_series/gp_intro.md b/docs/tutorials/goldenpath_series/gp_intro.md index cd8b3f897..9a6ecd29a 100644 --- a/docs/tutorials/goldenpath_series/gp_intro.md +++ b/docs/tutorials/goldenpath_series/gp_intro.md @@ -19,13 +19,13 @@ Next steps will likely involve the existing Golden Path series to be completely |
Hello World
|
Golden Path One
| | --- | --- | -| Creating a new project
Installing Netcode
Creating and testing the basic networking building blocks
| Adding scripts to objects
Editor modes (Host Server and Client)
Basic player movement
Basic RPC and Network variable use | +| [Creating a new project](../helloworld.md#create-a-new-project-in-unity)
[Installing Netcode](../helloworld.md#install-netcode)
[Creating and testing the basic networking building blocks](../helloworld.md#create-the-basic-components)
| [Editor modes (Host Server and Client)](gp_module_one.md#adding-editor-modes-to-hello-world)
[Basic player movement](gp_module_one.md#adding-basic-movement-to-the-player-object)
[Basic RPC and Network variable use](gp_module_one.md#some-simple-rpc-use) |
|
Golden Path Two
| | --- | -| Network variables (server-controlled)
Network transforms
More on RPCs| +| [Network variables (server-controlled)](gp_module_two.md#introducing-a-server-controlled-network-variable)
[Network transforms](gp_module_two.md#introducing-network-transform)
[More on RPCs](gp_module_two.md#introducing-rpcs)|
\ No newline at end of file From 2aa8b23b8d8ec97431b95334cfb7b2b127eeefe8 Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Wed, 2 Nov 2022 16:08:43 -0400 Subject: [PATCH 11/12] implementing requested changes --- docs/tutorials/goldenpath_series/gp_module_one.md | 4 ++-- docs/tutorials/helloworld.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/goldenpath_series/gp_module_one.md b/docs/tutorials/goldenpath_series/gp_module_one.md index 8ced0aa8a..29e4db916 100644 --- a/docs/tutorials/goldenpath_series/gp_module_one.md +++ b/docs/tutorials/goldenpath_series/gp_module_one.md @@ -140,7 +140,7 @@ namespace HelloWorld ```
-The `NetworkManager` instance can be accessed statically from any other scripts via its singleton named `Singleton`. This is defined when the `MonoBehaviour` is enabled. This component also contains very useful properties, such as `IsClient`, `IsServer`, and `IsLocalClient`. The first two dictate the connection state we have currently established that you will use shortly. +You can statically access the `NetworkManager` instance from any other scripts via its singleton named `Singleton`. This is defined when the `MonoBehaviour` is enabled. This component also contains very useful properties, such as `IsClient`, `IsServer`, and `IsLocalClient`. The `IsClient` and `IsServer` properties dictate the connection state we have currently established that you will use shortly. We call these methods inside of `OnGUI()`. @@ -298,7 +298,7 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.poc/tree/fea ```
-In a networked game, server/host machines may need to run different functions to a networked player/client. (For example, in a server-authoritative game, the client would handle the player inputs but the movement would be done on the server). All of the instances of this script in the game, whether they're the host/server or a client, will call the `OnNetworkSpawn` method when the `NetworkObject` to which this script is attached has spawned, but only its owner will call the `Move` method. In the case of a Player Object, every client (or host) will have one instance spawned for them, for which they will be the owner. Calling this in `OnNetworkSpawn` makes sure that the NetworkObject has finished spawning so the check to see whether the player is a Server/Host or Client is valid. The `Move` method can then implement different logic depending on the answer (so that Servers do one thing, and Clients do another). +In a networked game, the dedicated server (or host) might need to run different functions than the networked player (the client). For example, in a server-authoritative game, the client would handle the player inputs, but the server would handle the movement. All instances of this script in the game, whether running on a server/host or a client, call the `OnNetworkSpawn` method when the `NetworkObject` to which this script is attached has spawned, but only its owner will call the `Move` method. In the case of a Player Object, every client (or host) has an instance of the Player Object, which contains this script as a component, spawned for them by Netcode. Each client is the owner of the Player Object that was spawned for them. Calling the `Move` method in `OnNetworkSpawn` instead of in `Awake` ensures that the NetworkObject has finished spawning, so the check to see whether the player is a server/host or client is valid. The `Move` method can then implement different logic depending on the answer (so that servers do one thing, and clients do another).
Click to show/hide the Code. diff --git a/docs/tutorials/helloworld.md b/docs/tutorials/helloworld.md index 445659f62..dbcc8a7b2 100644 --- a/docs/tutorials/helloworld.md +++ b/docs/tutorials/helloworld.md @@ -30,7 +30,7 @@ In this section we will create the basic building blocks of a multiplayer game. ### Creating Network Manager and selecting the Transport -In this section we will add a Network Manager and add Unity Transport (UTP) to our project. The [NetworkManager](../components/networkmanager.md) is the component that contains all of your project's netcode related settings. UTP is the transport layer that Netcode will use for communication between the server and the clients. See [here](../advanced-topics/transports.md) for more. +In this section we add a Network Manager and add Unity Transport (UTP) to our project. The [NetworkManager](../components/networkmanager.md) is the component that contains all your project's netcode-related settings. UTP is the transport layer that Netcode uses for communication between the server and the clients. See [here](../advanced-topics/transports.md) for more. 1. Right-click in the **Hierarchy** tab of the main Unity Window. 1. Select **Create Empty**. @@ -296,7 +296,7 @@ Now, to see if everything works as expected we can test starting a host in the e 1. Click the **Start Host** button in the **NetworkManager** GameObject's inspector. 1. You should now see your scene with your Player Prefab spawned. -You can also use the command line helper to launch a server and one or more client that will connect to the server. You should then see the plane on the server, until the first client connects. Then, for each connected client, a new Player Prefab will be spawned. +You can also use the command line helper to launch a server and one or more clients to connect to the server. You should see the plane on the server until the first client connects. Then, a new Player Prefab will be spawned by Netcode for each connected client. ## Next Steps From 85c1a0052642e7a43048750149eb5b2c2091fa9a Mon Sep 17 00:00:00 2001 From: LPLafontaineB Date: Mon, 7 Nov 2022 11:36:12 -0500 Subject: [PATCH 12/12] implementing suggested changes --- docs/tutorials/goldenpath_series/gp_module_one.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/goldenpath_series/gp_module_one.md b/docs/tutorials/goldenpath_series/gp_module_one.md index 29e4db916..d761eb7a0 100644 --- a/docs/tutorials/goldenpath_series/gp_module_one.md +++ b/docs/tutorials/goldenpath_series/gp_module_one.md @@ -298,7 +298,7 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.poc/tree/fea ```
-In a networked game, the dedicated server (or host) might need to run different functions than the networked player (the client). For example, in a server-authoritative game, the client would handle the player inputs, but the server would handle the movement. All instances of this script in the game, whether running on a server/host or a client, call the `OnNetworkSpawn` method when the `NetworkObject` to which this script is attached has spawned, but only its owner will call the `Move` method. In the case of a Player Object, every client (or host) has an instance of the Player Object, which contains this script as a component, spawned for them by Netcode. Each client is the owner of the Player Object that was spawned for them. Calling the `Move` method in `OnNetworkSpawn` instead of in `Awake` ensures that the NetworkObject has finished spawning, so the check to see whether the player is a server/host or client is valid. The `Move` method can then implement different logic depending on the answer (so that servers do one thing, and clients do another). +In a networked game, the dedicated server (or host) might need to run different functions than the networked player (the client). For example, in a server-authoritative game, the client would handle the player inputs, but the server would handle the movement. All instances of this script in the game, whether running on a server/host or a client, call the `OnNetworkSpawn` method when the `NetworkObject` to which this script is attached has spawned, but only its owner will call the `Move` method. In the case of a [Player Object](../../basics/networkobject#player-objects), Netcode spawns an instance of the player object for every client and host (for which they are the owner). Each of these player objects contain this script. Calling the `Move` method in OnNetworkSpawn instead of, for example, in `Awake` ensures that the NetworkObject has finished spawning, so the check to see whether the player is a server/host or client is valid. The `Move` method can then implement different logic depending on the answer (so that servers do one thing, and clients do another).
Click to show/hide the Code.