Skip to content

Commit be9d1bb

Browse files
Larah ArmstrongchrispopeLPLafontaineBs-omeilia-unitySamuelBellomo
authored
Publish staged content (#888)
* Sync develop with main (#868) * Publish staged content (#852) * Merging Develop with Main (#813) (#826) * Updating docs page in 2D space shooter (#810) Updating docs page in 2D space shooter which has a reference to an unconfirmed feature (Prediction) * updating boss room example used in mid-game reconnecting doc (#725) Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Christopher Pope <[email protected]> * Update getting-started-boss-room.md (#812) Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> * small fixes for tutorials (#829) * renamed command line argument and variable in helloworld code snippet * fixing broken link in gp module 2 * fixing indentation issues in gp 1 code snippets * fixing log not corresponding to code example * updating gp table of contents * removing unneeded instructions * Update NGO changelog to 1.1.0 (#834) * Update NGO changelog to 1.1.0 * Add PR and issue links * In-Scene Placed NetworkObject updates for v1.1.0 (#816) * Merging Develop with Main (#813) * Updating docs page in 2D space shooter (#810) Updating docs page in 2D space shooter which has a reference to an unconfirmed feature (Prediction) * updating boss room example used in mid-game reconnecting doc (#725) Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Christopher Pope <[email protected]> * Update getting-started-boss-room.md (#812) Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> * Start 1.1.0 updates Just creating a branch to start working on v1.1.0 updates * update updated the spawning and despawning portion. * update Final first pass for in-scene placed NetworkObject documentation updates. * update adding temporary warning to users about in-scene placed NetworkObject parenting. Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> * WorldPositionStays update (#778) * WorldPositionStays update The update to this documentation requires NGO SDK PR-2146 before it should be made public/merged. * update Still WIP * update additions and adjustments. * update * update final pass adjustments for the PRs suggested updates. Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: Larah Armstrong <[email protected]> * Remove internal comment (#830) * update ClientNetworkTransform information (#791) * update ClientNetworkTransform information This just provides users with a bit more information about setting NetworkTransform into owner/client authoritative mode, * update adjusting the text copy and pointing the example of the ClientNetworkTransform to the co-op samples version * update Applying suggested update for section that outlines how to add the multiplayer samples utilities package to your project. Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: Larah Armstrong <[email protected]> * Updated existing or added missing dark themes to our sequence and scene diagrams! (#838) Co-authored-by: Larah Armstrong <[email protected]> * Add NGO 1.1.0 documentation (#839) * Bump version * update Adjusting the code example to be compliant with the recent updates. Adding additional information about the example in the note. * parenting update Adding some additional language to the parenting related documents and fixing a minor spelling issue. Co-authored-by: NoelStephensUnity <[email protected]> * NGO 1.1.0 release notes (#843) * Fix version drop-down order * Add NGO 1.1.0 release notes * fix: tutorial improvements (#840) * fixing typos and broken links * clarifying the Testing Hello World section * Clarified the usage of OnNetworkSpawn in HelloWorldPlayer * clarified Adding Editor Modes section in GP1 * clarified use of command line helper * Adding high-level explanation of what NetworkManager and UTP are in HelloWorld tutorial, with links to detailed docs * restructured GP1 to have instructions to add script after description of why we add them * adding links to gp_intro Co-authored-by: Larah Armstrong <[email protected]> * Add "coming soon" note to empty pages (#845) * Add Optimizing Boss Room Performance * Revert "Add Optimizing Boss Room Performance" This reverts commit 427c1f2. * Add Optimizing Boss Room Performance (#848) * Add Optimizing Boss Room Performance * Minor fixes * Implement feedback * Fix SceneEventType Typo (#850) * Publish staged content (#844) * Merging Develop with Main (#813) (#826) * Updating docs page in 2D space shooter (#810) Updating docs page in 2D space shooter which has a reference to an unconfirmed feature (Prediction) * updating boss room example used in mid-game reconnecting doc (#725) Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Christopher Pope <[email protected]> * Update getting-started-boss-room.md (#812) Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> * small fixes for tutorials (#829) * renamed command line argument and variable in helloworld code snippet * fixing broken link in gp module 2 * fixing indentation issues in gp 1 code snippets * fixing log not corresponding to code example * updating gp table of contents * removing unneeded instructions * Update NGO changelog to 1.1.0 (#834) * Update NGO changelog to 1.1.0 * Add PR and issue links * In-Scene Placed NetworkObject updates for v1.1.0 (#816) * Merging Develop with Main (#813) * Updating docs page in 2D space shooter (#810) Updating docs page in 2D space shooter which has a reference to an unconfirmed feature (Prediction) * updating boss room example used in mid-game reconnecting doc (#725) Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Christopher Pope <[email protected]> * Update getting-started-boss-room.md (#812) Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> * Start 1.1.0 updates Just creating a branch to start working on v1.1.0 updates * update updated the spawning and despawning portion. * update Final first pass for in-scene placed NetworkObject documentation updates. * update adding temporary warning to users about in-scene placed NetworkObject parenting. Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> * WorldPositionStays update (#778) * WorldPositionStays update The update to this documentation requires NGO SDK PR-2146 before it should be made public/merged. * update Still WIP * update additions and adjustments. * update * update final pass adjustments for the PRs suggested updates. Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: Larah Armstrong <[email protected]> * Remove internal comment (#830) * update ClientNetworkTransform information (#791) * update ClientNetworkTransform information This just provides users with a bit more information about setting NetworkTransform into owner/client authoritative mode, * update adjusting the text copy and pointing the example of the ClientNetworkTransform to the co-op samples version * update Applying suggested update for section that outlines how to add the multiplayer samples utilities package to your project. Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: Larah Armstrong <[email protected]> * Updated existing or added missing dark themes to our sequence and scene diagrams! (#838) Co-authored-by: Larah Armstrong <[email protected]> * Add NGO 1.1.0 documentation (#839) * Bump version * update Adjusting the code example to be compliant with the recent updates. Adding additional information about the example in the note. * parenting update Adding some additional language to the parenting related documents and fixing a minor spelling issue. Co-authored-by: NoelStephensUnity <[email protected]> * NGO 1.1.0 release notes (#843) * Fix version drop-down order * Add NGO 1.1.0 release notes * fix: tutorial improvements (#840) * fixing typos and broken links * clarifying the Testing Hello World section * Clarified the usage of OnNetworkSpawn in HelloWorldPlayer * clarified Adding Editor Modes section in GP1 * clarified use of command line helper * Adding high-level explanation of what NetworkManager and UTP are in HelloWorld tutorial, with links to detailed docs * restructured GP1 to have instructions to add script after description of why we add them * adding links to gp_intro Co-authored-by: Larah Armstrong <[email protected]> * Add "coming soon" note to empty pages (#845) * Add Optimizing Boss Room Performance * Revert "Add Optimizing Boss Room Performance" This reverts commit 427c1f2. Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Noel Stephens <[email protected]> Co-authored-by: Jil Franco <[email protected]> Co-authored-by: NoelStephensUnity <[email protected]> * Fix SceneEventType Typo LoadEvenetCompleted should be LoadEventCompleted. Refer to: https://docs-multiplayer.unity3d.com/netcode/current/api/Unity.Netcode.SceneEventType/index.html Co-authored-by: Larah Armstrong <[email protected]> Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Noel Stephens <[email protected]> Co-authored-by: Jil Franco <[email protected]> Co-authored-by: NoelStephensUnity <[email protected]> * Simplify Boss Room Get started page (#851) * Make Get started reflect the README * Implement suggestions * Info about ParrelSync with Unity Authentication (#795) * Info about ParrelSync with Unity Authentication Add some information about using ParrelSync with Unity Authentication. Include a code snippet showing how to use the ClonesManager to automatically switch player profiles. * Implement suggested changes Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: Larah Armstrong <[email protected]> Co-authored-by: Larah Armstrong <[email protected]> * Add Network Simulator documentation (#853) * Add Network Simulator docs * Add to sidebar * Fix hard line breaks * Implement suggested changes * Implement suggested changes * Add versioning for Tools and switch the latest to 1.1.0 * Add Tools 1.1.0 SDK documentation * Remove test pages (#862) Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Noel Stephens <[email protected]> Co-authored-by: Jil Franco <[email protected]> Co-authored-by: NoelStephensUnity <[email protected]> Co-authored-by: Hunter <[email protected]> Co-authored-by: Ben Randall <[email protected]> * Fixed typo in messaging-system.md (#864) NetworkVariables was spelt *Newt*orkVariable (lol) * Update networkobject.md (#860) Co-authored-by: Larah Armstrong <[email protected]> * docs: fix broken copy/paste link (#855) This fixes the broken copy/paste link for adding the Multiplayer Samples Utilities package. Co-authored-by: Larah Armstrong <[email protected]> Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Noel Stephens <[email protected]> Co-authored-by: Jil Franco <[email protected]> Co-authored-by: NoelStephensUnity <[email protected]> Co-authored-by: Hunter <[email protected]> Co-authored-by: Ben Randall <[email protected]> Co-authored-by: Walter Hulsebos <[email protected]> Co-authored-by: Alex Robinson <[email protected]> Co-authored-by: Jonas Lagoni <[email protected]> * Update PR template with warning (#869) * Fixed misleading example about NetworkList (#854) Fixed misleading example about NetworkList, and added a more extensive example to display how to react on NetworkList changes specifically on the server/client Co-authored-by: Larah Armstrong <[email protected]> * Update ClientDriven.md with updated scripting references (#865) Co-authored-by: Larah Armstrong <[email protected]> * chore: Managed Netvar documentation (#818) * Update UTP 2.0 documentation (#875) * Update UTP 2.0 documentation * Add images * Fix pipeline image * Swap pipeline image order * Bump loader-utils from 1.4.0 to 1.4.1 (#847) Bumps [loader-utils](https://github.com/webpack/loader-utils) from 1.4.0 to 1.4.1. - [Release notes](https://github.com/webpack/loader-utils/releases) - [Changelog](https://github.com/webpack/loader-utils/blob/v1.4.1/CHANGELOG.md) - [Commits](webpack/loader-utils@v1.4.0...v1.4.1) --- updated-dependencies: - dependency-name: loader-utils dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Larah Armstrong <[email protected]> * Bump decode-uri-component from 0.2.0 to 0.2.2 (#874) Bumps [decode-uri-component](https://github.com/SamVerschueren/decode-uri-component) from 0.2.0 to 0.2.2. - [Release notes](https://github.com/SamVerschueren/decode-uri-component/releases) - [Commits](SamVerschueren/decode-uri-component@v0.2.0...v0.2.2) --- updated-dependencies: - dependency-name: decode-uri-component dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Larah Armstrong <[email protected]> * Add MPPM documentation (#881) * Update NGO about topic (#886) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Christopher Pope <[email protected]> Co-authored-by: LPLafontaineB <[email protected]> Co-authored-by: Sara [Unity] <[email protected]> Co-authored-by: Sam Bellomo <[email protected]> Co-authored-by: Noel Stephens <[email protected]> Co-authored-by: Jil Franco <[email protected]> Co-authored-by: NoelStephensUnity <[email protected]> Co-authored-by: Hunter <[email protected]> Co-authored-by: Ben Randall <[email protected]> Co-authored-by: Walter Hulsebos <[email protected]> Co-authored-by: Alex Robinson <[email protected]> Co-authored-by: Jonas Lagoni <[email protected]> Co-authored-by: Paolo Abela <[email protected]> Co-authored-by: Fernando Cortez <[email protected]> Co-authored-by: Kitty Draper <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 842a134 commit be9d1bb

File tree

13 files changed

+277
-11
lines changed

13 files changed

+277
-11
lines changed

docs/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Don't forget to check out our [Release Notes](https://docs-multiplayer.unity3d.c
2929
## Before you begin
3030

3131
Netcode supports the following versions:
32-
* Unity 2020.3, 2021.1, 2021.2, and 2021.3
32+
* Unity 2020.3, 2021.1, 2021.2, 2021.3, and 2022.
3333
* Mono and IL2CPP [Scripting Backends](https://docs.unity3d.com/Manual/scripting-backends.html)
3434

3535
Netcode supports the following platforms:

sidebarsTools.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ module.exports = {
1515
{
1616
"type": "doc",
1717
"id": "tools-network-simulator"
18+
},
19+
{
20+
"type": "doc",
21+
"id": "mppm"
1822
}
1923
],
2024

static/img/tools/mppm-01.png

27.2 KB
Loading

static/img/tools/mppm-02.png

31.5 KB
Loading

static/img/tools/mppm-03.png

28.2 KB
Loading

static/img/tools/mppm-04.png

7.57 KB
Loading

static/img/tools/mppm-05.png

19.4 KB
Loading

static/img/tools/mppm-06.png

27.7 KB
Loading

static/img/tools/mppm-07.png

27 KB
Loading

static/img/tools/mppm-08.png

27.6 KB
Loading

static/img/tools/mppm-09.png

27.1 KB
Loading

tools/mppm.md

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
---
2+
id: mppm
3+
title: Multiplayer Play Mode
4+
sidebar_label: Multiplayer Play Mode
5+
---
6+
7+
Multiplayer Play Mode (MPPM) enables you to test multiplayer functionality without leaving the Unity Editor. You can simulate up to four Players (the Main Editor Player plus three Virtual Players) simultaneously on the same development device while using the same source assets on disk. You can leverage MPPM to create multiplayer development workflows that reduce the time it takes to build a project, run it locally, and test the server-client relationship.
8+
9+
This document uses the following terminology to distinguish between the primary Unity Editor project and the Virtual Player instances:
10+
11+
- The **Main Editor** refers to the primary (or original) instance of the project in the Unity Editor, and this is the only instance with full authoring capabilities.
12+
- **Virtual Players** refers to simulated Players created with Multiplayer Play Mode that open in a separate window with limited authoring capabilities when you enter **[Play mode](https://docs.unity3d.com/Manual/GameView.html)**.
13+
- **Players** refers to all Player instances, including the Main Editor Player and all Virtual Players.
14+
15+
## Requirements
16+
17+
You must meet the following requirements to use Multiplayer Play Mode:
18+
19+
- Install Unity Editor version 2023.1 or later
20+
- Install the `com.unity.multiplayer.playmode` package (version 0.1.0 or later)
21+
22+
### Limitations
23+
24+
MPPM has some inherent technical limitations, specifically around [scale](#scale) and [authoring](#authoring).
25+
26+
#### Scale
27+
28+
The Unity Editor (and Virtual Player instances) require a lot of system resources; as a result, you shouldn’t use MPPM at scale. It’s designed for use in small-scale, local testing environments. By default, MPPM supports up to four Players (the Main Editor plus three Virtual Players).
29+
30+
#### Authoring
31+
32+
Virtual Player instances open in a Unity Editor window when you enter Play mode. These instances have restricted authoring capabilities because they’re intended as a vehicle to open multiple project runtimes, not to offer multi-editor authoring workflows.
33+
34+
You should use the Main Editor to make changes and the Virtual Players to test multiplayer functionality. This way, you can continue to use existing Editor workflows without learning how to use the Unity Editor in new ways.
35+
36+
You can't access any functionality of the Main Editor from Virtual Players.
37+
38+
### Performance impact
39+
40+
Each Virtual Player increases the demand for system resources. MPPM limits the performance impact of Virtual Players by sharing specific resources, such as the artifact database and imports, between the Main Editor and each Virtual Player.
41+
42+
## Getting started
43+
44+
You can access MPPM by opening the Multiplayer Play Mode window: Select **Window** > **Multiplayer Play Mode**.
45+
46+
![MPPM Window](../static/img/tools/mppm-05.png)
47+
48+
The Multiplayer Play Mode window allows you to access Virtual Players and Player Tags.
49+
50+
## Players
51+
52+
Players represent either the Main Editor Player or the Virtual Players that you can enable and disable with the checkbox next to the Virtual Player name (from the Multiplayer Play Mode window). There are four available Player slots:
53+
54+
- Player 1 (The Main Editor)
55+
- Player 2 (Virtual Player)
56+
- Player 3 (Virtual Player)
57+
- Player 4 (Virtual Player)
58+
59+
### Enable a Virtual Player
60+
61+
You can enable up to four Players simultaneously (the Main Editor Player plus three Virtual Players). Note that you must activate Virtual Players before entering **Play mode**.
62+
63+
To enable a Virtual Player:
64+
65+
1. Select the checkbox next to the Virtual Player name (for example, Player 2).
66+
67+
![Enable Virtual Player](../static/img/tools/mppm-03.png)
68+
69+
2. Wait for Unity to activate the Virtual Player.
70+
3. After the Player is activated, the status changes from **Activating** to **Active**, and you can use the Virtual Player in testing.
71+
72+
![Enable Virtual Player](../static/img/tools/mppm-06.png)
73+
74+
4. Select the **Play** button in the Main Editor.
75+
76+
A Unity Editor Play Mode window should open for each enabled Player (with the window titled after the Player name).
77+
78+
## Player Tags
79+
80+
You can think of Player Tags like launch arguments for Players (the Main Editor Player and Virtual Players). You can configure Player Tags to do things such as:
81+
82+
- Configure a Player to run as a client, server, or host automatically.
83+
- Configure a Player to automatically run as a member of a specific team (for example, “Red Team” or “Blue Team”).
84+
- Configure a Player to move faster or slower.
85+
86+
### Attach a Player Tag to a Player
87+
88+
You can attach a Player Tag to a Player by selecting the Player Tag from the Tag drop-down list. In the following example, a single Player Tag (named "Fast") configures a Virtual Player to allow the Player to move faster than the other Players.
89+
90+
:::warning
91+
You can't attach a Player Tag to an active Player. You must first disable the Player, then attach the Player Tag.
92+
:::
93+
94+
1. Select the Player Tag from the **Tag** drop-down for the Player.
95+
96+
![Enable Fast Player](../static/img/tools/mppm-07.png)
97+
98+
2. Enable the Player by selecting the checkbox to its left.
99+
100+
![Enable Virtual Player](../static/img/tools/mppm-08.png)
101+
102+
### Add a Player Tag
103+
104+
You can add a Player Tag through the Multiplayer Play Mode window. When you add a Player Tag, it’s automatically added to the `VirtualProjectsConfig.json` file in the `ProjectsSettings` folder.
105+
106+
1. Select the **+** symbol under Player Tags.
107+
108+
![Add Player Tag](../static/img/tools/mppm-01.png)
109+
110+
2. Name the Player Tag.
111+
112+
![Name the Player Tag](../static/img/tools/mppm-02.png)
113+
114+
3. Select **Save**.
115+
116+
You should now see the new Player Tag listed under Player Tags and in the drop-down menu for the Tag option of each Player.
117+
118+
![Player Tag](../static/img/tools/mppm-09.png)
119+
120+
### Configuring Player Tags
121+
122+
Alone, Player Tags don’t do much at all. You have to target the Player Tag in your game scripts with `CurrentPlayer.Tag`. See the following Player Tag examples:
123+
124+
- [Run as a server, client, or host](#run-as-a-server-client-or-host)
125+
- [Automatically assign to team](#automatically-assign-to-team)
126+
- [Simulate network conditions](#simulate-network-conditions)
127+
128+
There’s no restriction on where you can keep these scripts that work with Player Tags, but you must attach the scripts to a [NetworkObject](../docs/basics/networkobject.md) (such as the Player).
129+
130+
The logic in some of the following examples checks if the Player Tag has a string rather than if it’s equal to a string to allow for more flexibility with the name of the Player Tag. You can also change this logic so that it checks for an exact match.
131+
132+
:::note
133+
Some of the following examples use the `Contains` method, which is case-sensitive by default, but you can make it case-insensitive by passing the `System.StringComparison.CurrentCultureIgnoreCase` method.
134+
:::
135+
136+
#### Run as a server, client, or host
137+
138+
The following script uses the Netcode for GameObjects [NetworkManager](../docs/components/networkmanager.md) to automatically connect the Virtual Player as a server, client, or host based on the attached Player Tag. For example, a Player with the “Server” Player Tag automatically runs as a server, and a Player with the “Client” Player Tag automatically runs as a client.
139+
140+
:::note
141+
This example uses [Netcode for GameObjects (NGO)](../docs/about.md).
142+
:::
143+
144+
```csharp
145+
using Unity.Netcode;
146+
using UnityEngine;
147+
using Unity.Multiplayer.Playmode;
148+
149+
/// A MonoBehaviour to automatically start Netcode for GameObjects
150+
/// clients, hosts, and servers
151+
public class MppmConnect : MonoBehaviour
152+
{
153+
void Start()
154+
{
155+
var mppmTag = CurrentPlayer.Tag;
156+
var networkManager = NetworkManager.Singleton;
157+
if (mppmTag.Contains("Server"))
158+
{
159+
networkManager.StartServer();
160+
}
161+
else if (mppmTag.Contains("Host"))
162+
{
163+
networkManager.StartHost();
164+
}
165+
else if (mppmTag.Contains("Client"))
166+
{
167+
networkManager.StartClient();
168+
}
169+
}
170+
}
171+
```
172+
173+
#### Automatically assign to team
174+
175+
The following script automatically sets a [NetworkVariable](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkvariable) called `Team` based on the Player Tag. For example, a Player with a Player Tag named “Red” automatically sets the `Team` NetworkVariable to Red. A Player with a Player Tag named “Blue” automatically sets the `Team` NetworkVariable to Blue.
176+
177+
```csharp
178+
using Unity.Netcode;
179+
using UnityEngine;
180+
using Unity.Multiplayer.Playmode;
181+
182+
public enum Team { Blue, Red, }
183+
184+
/// A player with a team that is automatically assigned
185+
/// based on the Player Tag of the client that owns them
186+
public class Player : NetworkBehaviour
187+
{
188+
public NetworkVariable<Team> team = new (writePerm: NetworkVariableWritePermission.Owner);
189+
190+
void Start()
191+
{
192+
var localClientId = NetworkManager.Singleton.LocalClientId;
193+
if (!team.CanClientWrite(localClientId))
194+
{
195+
return;
196+
}
197+
var mppmTag = CurrentPlayer.Tag;
198+
if (mppmTag.Contains("Blue"))
199+
{
200+
team.Value = Team.Blue;
201+
}
202+
if (mppmTag.Contains("Red"))
203+
{
204+
team.Value = Team.Red;
205+
}
206+
}
207+
}
208+
```
209+
210+
#### Simulate network conditions
211+
212+
The following script uses Network Simulation Presets from the Multiplayer Tools package to automatically apply a fast or slow network based on the Player Tag. In this example, a Player with the “FastNetwork” Player Tag simulates a common [Home Broadband](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator#home-broadband) connection, and a Player with the “SlowNetwork” Player Tag simulates a [Mobile 2.5G](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator#mobile-25g) connection.
213+
214+
:::note
215+
This example uses the [Network Simulator](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator) tool from the `com.unity.multiplayer.tools` package.
216+
:::
217+
218+
```csharp
219+
using System.Collections;
220+
using System.Collections.Generic;
221+
using UnityEngine;
222+
using Unity.Multiplayer.Playmode;
223+
using Unity.Multiplayer.Tools.NetworkSimulator.Runtime;
224+
225+
public class NetworkSimulatotion : MonoBehaviour
226+
{
227+
void Start()
228+
{
229+
var networkSimulator = GetComponent<NetworkSimulator>() ??
230+
gameObject.AddComponent<NetworkSimulator>();
231+
232+
var connectionPreset = NetworkSimulatorPresets.None;
233+
if (CurrentPlayer.Tag == "FastNetwork")
234+
{
235+
connectionPreset = NetworkSimulatorPresets.HomeBroadband;
236+
}
237+
else if (CurrentPlayer.Tag == "SlowNetwork")
238+
{
239+
connectionPreset = NetworkSimulatorPresets.Mobile2_5G;
240+
}
241+
242+
networkSimulator.ConnectionPreset = connectionPreset;
243+
}
244+
}
245+
```
246+
247+
## Synchronized Play mode
248+
249+
When you enter [Play mode](https://docs.unity3d.com/Manual/GameView.html), Multiplayer Play Mode synchronizes the Main Editor and Virtual Players. If you select **Pause** or **Step** in the Main Editor [Toolbar](https://docs.unity3d.com/Manual/Toolbar.html), all Virtual Players follow suit. Enabling **Error Pause** in the [Console](https://docs.unity3d.com/Manual/Console.html) of any Player sets all Virtual Players to pause when you call `Debug.LogError` from a script.
250+
251+
### Using Pause/Step
252+
253+
Because MPPM synchronizes [Play mode](https://docs.unity3d.com/Manual/GameView.html) between the Main Editor and Virtual Players, you can use the Play, Pause, and Step actions the same way you do in a standard Unity Editor workflow.
254+
255+
![Editor Modes](../static/img/tools/mppm-04.png)
256+
257+
1. Selecting **Play** runs all activated Players.
258+
2. Selecting **Pause** pauses all activated Players.
259+
3. Selecting **Step** performs a single frame step for all activated Players.

yarn.lock

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5706,9 +5706,9 @@ decamelize@^1.1.2, decamelize@^1.2.0:
57065706
integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=
57075707

57085708
decode-uri-component@^0.2.0:
5709-
version "0.2.0"
5710-
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
5711-
integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=
5709+
version "0.2.2"
5710+
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9"
5711+
integrity sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==
57125712

57135713
decompress-response@^3.3.0:
57145714
version "3.3.0"
@@ -8303,9 +8303,9 @@ [email protected], loader-utils@^2.0.0:
83038303
json5 "^2.1.2"
83048304

83058305
loader-utils@^1.2.3, loader-utils@^1.4.0:
8306-
version "1.4.0"
8307-
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613"
8308-
integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==
8306+
version "1.4.1"
8307+
resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.1.tgz#278ad7006660bccc4d2c0c1578e17c5c78d5c0e0"
8308+
integrity sha512-1Qo97Y2oKaU+Ro2xnDMR26g1BwMT29jNbem1EvcujW2jqt+j5COXyscjM7bLQkM9HaxI7pkWeW7gnI072yMI9Q==
83098309
dependencies:
83108310
big.js "^5.2.2"
83118311
emojis-list "^3.0.0"
@@ -8556,9 +8556,7 @@ mdurl@^1.0.0:
85568556
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
85578557
integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=
85588558

8559-
8560-
mdx-mermaid@^1.3.2:
8561-
8559+
mdx-mermaid@^v1.3.0:
85628560
version "1.3.2"
85638561
resolved "https://registry.yarnpkg.com/mdx-mermaid/-/mdx-mermaid-1.3.2.tgz#9a9d335368de88f0c771daf12dde855bc6b67d57"
85648562
integrity sha512-8kw0tg3isKKBFzFwoe2DhIaEgKYtVeJXQtxZCCrdTPO0CTpXHnTHT0atDqsp7YkXi5iUCp/zAZPZu1cmr68T3w==
@@ -8765,11 +8763,16 @@ [email protected], minimatch@^3.0.4, minimatch@~3.0.2:
87658763
dependencies:
87668764
brace-expansion "^1.1.7"
87678765

8768-
minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5:
8766+
minimist@^1.1.3, minimist@^1.2.5:
87698767
version "1.2.6"
87708768
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
87718769
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
87728770

8771+
minimist@^1.2.0:
8772+
version "1.2.7"
8773+
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
8774+
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==
8775+
87738776
minipass@^3.0.0, minipass@^3.1.1:
87748777
version "3.1.5"
87758778
resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.5.tgz#71f6251b0a33a49c01b3cf97ff77eda030dff732"

0 commit comments

Comments
 (0)