Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

small fixes for tutorials #829

Merged
merged 9 commits into from
Oct 19, 2022
Merged
4 changes: 2 additions & 2 deletions docs/tutorials/goldenpath_series/gp_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Next steps will likely involve the existing Golden Path series to be completely

|<div class="buttons-pages">Hello World</div>| <div class="buttons-pages">Golden Path One</div>|
| --- | --- |
| Creating a new project<br/> Installing Netcode<br/> Creating and testing the basic networking building blocks<br/> | Adding scripts to objects<br/> Editor modes (Host Server and Client)<br/> Basic player movement <br/>Basic RPC use |
| Creating a new project<br/> Installing Netcode<br/> Creating and testing the basic networking building blocks<br/> | Adding scripts to objects<br/> Editor modes (Host Server and Client)<br/> Basic player movement <br/>Basic RPC and Network variable use |
</div>
<div class="table-columns-plain">

| <div class="buttons-pages">Golden Path Two</div>|
| --- |
| Network variables (client and server-controlled)<br/> Network transforms <br/> More on RPCs|
| Network variables (server-controlled)<br/> Network transforms <br/> More on RPCs|


</div>
4 changes: 2 additions & 2 deletions docs/tutorials/goldenpath_series/gp_module_one.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace HelloWorld
GUILayout.Label("Mode: " + mode);
}

static void SubmitNewPosition()
static void SubmitNewPosition()
{
if (GUILayout.Button(NetworkManager.Singleton.IsServer ? "Move" : "Request Position Change"))
{
Expand Down Expand Up @@ -218,7 +218,7 @@ We call these methods inside of `OnGUI()`.

```csharp

void OnGUI()
void OnGUI()
{
GUILayout.BeginArea(new Rect(10, 10, 300, 300));
if (!NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)
Expand Down
13 changes: 6 additions & 7 deletions docs/tutorials/goldenpath_series/gp_module_two.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ Now we will test the Server-controlled Network Variable works as we intended.

1. Select **File > Build and Run**.
1. Stop the player.
2. Launch the client and server together in a terminal as shown in [Testing the command line helper](#testing-the-command-line-helper).
2. Launch the client and server together in a terminal as shown in [Testing the command line helper](../helloworld.md#testing-the-command-line-helper).
3. After a brief delay, the client and server will spawn.
4. You should see the following in the console, showing that the server and client are sharing the variable:


```
Server's var initialized to: 0
Server set its var to: 0.1, has client var at: 0
Server set its var to: 3.099999, has client var at: 2.6
Server set its var to: 6.099997, has client var at: 5.599997
Server set its var to: 0.1
Server set its var to: 3.099999
Server set its var to: 6.099997
```
:::note
Since the printing to the terminal does not happen on every tick, the numbers will not match up perfectly.
Expand Down Expand Up @@ -162,9 +162,8 @@ This section adds some basic RPCs to the project.
1. Click the **Player** prefab.
1. In the **Player** prefab Inspector tab, click **Add Component**.
1. Click **Scripts**, and add the `RpcTest.cs` script you created earlier.
1. Right Click **Player** prefab.
1. Open the `RpcTest.cs` script.
1. Edit the `RpcTest.cs` script to match the following.
2. Open the `RpcTest.cs` script.
3. Edit the `RpcTest.cs` script to match the following.

<details open>
<summary>Click to show/hide the Code.
Expand Down
30 changes: 14 additions & 16 deletions docs/tutorials/helloworld.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ This section adds in a player object and spawns it for each connected player.
:::

5. Select `NetworkManager`.
6. Inside the `NetworkManager` component tab, locate the `NetworkPrefabs` field.
7. Click `+` to create a slot.
8. Drag this player prefab from above into the new empty slot
9. Drag the prefab also into the `Player Prefab` slot.
6. Inside the `NetworkManager` component tab, locate the `Player Prefab` field.
7. Drag this player prefab from above into this field.

:::important
When you drop the prefab into the `Player Prefab` slot, you are telling the library that when a client connects to the game, automatically spawn this prefab as the character for the connecting client. If you do not have any prefab set as the `Player Prefab` no player object will be spawned.
Expand Down Expand Up @@ -127,9 +125,9 @@ public class NetworkCommandLine : MonoBehaviour

var args = GetCommandlineArgs();

if (args.TryGetValue("-mlapi", out string mlapiValue))
if (args.TryGetValue("-mode", out string mode))
{
switch (mlapiValue)
switch (mode)
{
case "server":
netManager.StartServer();
Expand Down Expand Up @@ -216,22 +214,22 @@ You may get a UAC prompt requesting permission for the binary to run you should

Server:
```
<Path to Project>\Build\HelloWorld.exe -mlapi server
<Path to Project>\Build\HelloWorld.exe -mode server
```

Client:
```
<path to project>\Build\HelloWorld.exe -mlapi client
<path to project>\Build\HelloWorld.exe -mode client
```

To run these commands on a single line:
```
HelloWorld\Build\HelloWorld.exe -mlapi server & HelloWorld\Build\HelloWorld.exe -mlapi client
HelloWorld\Build\HelloWorld.exe -mode server & HelloWorld\Build\HelloWorld.exe -mode client
```

Example:
```
C:\Users\sarao>HelloWorld\Build\HelloWorld.exe -mlapi server & HelloWorld\Build\HelloWorld.exe -mlapi client
C:\Users\sarao>HelloWorld\Build\HelloWorld.exe -mode server & HelloWorld\Build\HelloWorld.exe -mode client
```

:::important
Expand All @@ -247,17 +245,17 @@ Modify the commands as follows:

Server:
```
<Path to Project>\Build\HelloWorld.exe -logfile log-server.txt -mlapi server
<Path to Project>\Build\HelloWorld.exe -logfile log-server.txt -mode server
```

Client:
```
<Path to Project>\Build\HelloWorld.exe -logfile log-client.txt -mlapi client
<Path to Project>\Build\HelloWorld.exe -logfile log-client.txt -mode client
```

Example (Running as a single command line):
```
C:\Users\sarao>HelloWorld\Build\HelloWorld.exe -logfile -log-server.txt -mlapi server & HelloWorld\Build\HelloWorld.exe -logfile log-client.txt -mlapi client
C:\Users\sarao>HelloWorld\Build\HelloWorld.exe -logfile -log-server.txt -mode server & HelloWorld\Build\HelloWorld.exe -logfile log-client.txt -mode client
```
:::

Expand All @@ -272,17 +270,17 @@ For Mac you should do the following:

Server
```
<Path to Project>/Build/HelloWorld.app/Contents/MacOS/<Project Name> -mlapi server -logfile -
<Path to Project>/Build/HelloWorld.app/Contents/MacOS/<Project Name> -mode server -logfile -
```

Client
```
<Path to Project>/Build/HelloWorld.app/Contents/MacOS/<Project Name> -mlapi client -logfile -
<Path to Project>/Build/HelloWorld.app/Contents/MacOS/<Project Name> -mode client -logfile -
```

Run both as a single command:
```
<Path to Project>/Build/HelloWorld.app/Contents/MacOS/<Project Name> -mlapi server -logfile - & ; ~ <Path to Project>/Build/HelloWorld.app/Contents/MacOS/<Project Name> -mlapi client -logfile -
<Path to Project>/Build/HelloWorld.app/Contents/MacOS/<Project Name> -mode server -logfile - & ; ~ <Path to Project>/Build/HelloWorld.app/Contents/MacOS/<Project Name> -mode client -logfile -
```
</TabItem>
</Tabs>
Expand Down