Skip to content

Commit 950baec

Browse files
authored
Develop into main for MPPM 1.3 (#1302)
2 parents 341b19c + 12db55d commit 950baec

25 files changed

+824
-1
lines changed

docusaurus.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,13 @@ module.exports = {
369369
lastVersion: "current",
370370
versions: {
371371
current: {
372-
label: "1.2.0",
372+
label: "1.3.0",
373373
path: "current",
374374
},
375+
"1.2.0": {
376+
label: "1.2.0",
377+
path: "1.2.0",
378+
},
375379
"1.1.0": {
376380
label: "1.1.0",
377381
path: "1.1.0",

mppm/release-notes/release-notes.md

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ title: Release notes
44
description: Release notes for Multiplayer Play Mode including new features, updates, bug fixes, and known issues.
55
---
66

7+
## [1.3.0-exp.2] - 2024-07-03
8+
9+
### Fixed
10+
- Fixed an issue to make the **Stream logs to main editor** property work in local instances.
11+
12+
## [1.3.0-exp.1] - 2024-06-24
13+
14+
### Added
15+
- Added the Playmode Scenarios window that you can use to configure Editor, local and remote instances.
16+
17+
### Fixed
18+
- No longer hit an exception when launching the standalone profiler.
19+
720
## [1.2.0] - 2024-06-04
821

922
### Added
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
id: about
3+
title: About Multiplayer Play Mode
4+
description: Overview of Multiplayer Play Mode
5+
---
6+
7+
Use Multiplayer Play Mode to test multiplayer functionality within the Unity Editor. You can simulate up to four Players (the main Editor Player and three Virtual Players) simultaneously on the same development device while using the same source assets on disk. Multiplayer Play Mode can help you create multiplayer development workflows that reduce project build times, run it locally, and test the server-client relationship.
8+
9+
## Compatibility
10+
11+
Multiplayer Play Mode version 1.1.0 is compatible with Unity Editor versions 6000.0.3f1 or later.
12+
13+
## Compatibility
14+
15+
Multiplayer Play Mode version 1.1.0 is compatible with Unity Editor versions 6000.0.3f1 or later.
16+
17+
## Multiplayer Play Mode terminology
18+
19+
The following have specific meaning in relation to Multiplayer Play Mode:
20+
21+
* main Editor Player: The original instance of the project in the Unity Editor. This is the only instance with full authoring capabilities.
22+
* Virtual Players: Simulated Players created with Multiplayer Play Mode. These Players open in a separate window with limited authoring capabilities when you enter [Play mode](https://docs.unity3d.com/Manual/GameView.html).
23+
* Players: All Player instances, including the main Editor Player and all Virtual Players.
24+
25+
## Limitations
26+
27+
Multiplayer Play Mode has some inherent technical limitations, specifically around [scale](#scale) and [authoring](#authoring).
28+
29+
### Scale
30+
31+
The Unity Editor and Virtual Players require a lot of system resources, so you shouldn't use Multiplayer Play Mode at scale. Multiplayer Play Mode is designed for small-scale, local testing environments that can only support up to four total Players (the main Editor Player and three Virtual Players).
32+
33+
### Authoring
34+
You can't create or change the properties of GameObjects in a Virtual Player. Instead, use the main Editor Player to make changes and a Virtual Player to test multiplayer functionality. Any changes you make in Play Mode in the main Editor Player reset when you exit Play Mode.
35+
:::note
36+
You can't access any main Editor Player functionality from Virtual Players.
37+
:::
38+
39+
## Performance impact
40+
41+
To reduce the demand on system resources caused by each Virtual Player instance, Multiplayer Play Mode shares specific resources, such as the artifact database and imports between the main Editor Player and each Virtual Player.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
id: multiplayer-role
3+
title: Assign Virtual Players to a multiplayer role
4+
description: Learn how to use the dedicated server package to assign Virtual Players to a multiplayer role.
5+
---
6+
7+
Install the [Dedicated Server package](https://docs.unity3d.com/Packages/[email protected]/manual/index.html) with Multiplayer Play Mode to switch Players between the server and client role without a script.
8+
9+
::: Important
10+
To avoid errors, install the Dedicated Server package version that is the same as the Multiplayer Play mode version that exists in your project.
11+
:::
12+
13+
## Set the main Editor Player multiplayer role
14+
15+
To set the role of a the main Editor Player, do the following:
16+
17+
1. Open the Multiplayer Play Mode inspector (**Multiplayer** > **Multiplayer Play Mode**).
18+
2. In the **main Editor Player** section, expand the **Multiplayer Role** dropdown.
19+
3. Select the [multiplayer role](https://docs.unity3d.com/Packages/[email protected]/manual/multiplayer-roles.html) you want the main Editor Player to use.
20+
21+
## Set the multiplayer role of a Virtual Player
22+
23+
To set the role of a [Virtual Player](../../virtual-players), do the following:
24+
25+
1. Open the Multiplayer Play Mode inspector (**Multiplayer** > **Multiplayer Play Mode**).
26+
2. In the **Virtual Players** section, expand a Virtual Player's **Multiplayer Role** dropdown.
27+
3. Select the [multiplayer role](https://docs.unity3d.com/Packages/[email protected]/manual/multiplayer-roles.html) you want this Player to use.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
id: play-mode-dedicated-server
3+
title: Use Multiplayer Play mode with a Dedicated Server
4+
description: Use the dedicated server package with multiplayer play mode.
5+
---
6+
7+
The [Dedicated Server package](https://docs.unity3d.com/Packages/[email protected]/manual/index.html) adds [multiplayer roles](https://docs.unity3d.com/Packages/[email protected]/manual/multiplayer-roles.html) to the [Dedicated Server build platform](https://docs.unity3d.com/Manual/dedicated-server-introduction.html). You can use multiplayer roles to assign virtual players to a client, server, or client and server multiplayer role.
8+
9+
<!--
10+
<div className="table-columns-plain" >
11+
| Page | Description |
12+
</div>
13+
-->
14+
15+
|**Page** |**Description**|
16+
|-|-|
17+
|[Debug Multiplayer Play Mode](debug-mppm.md)| Learn how to use Unity Test Framework to test a project with Multiplayer Play Mode. |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
id: install
3+
title: Install Multiplayer Play Mode
4+
description: How to install Multiplayer Play Mode
5+
---
6+
7+
You can use Multiplayer Play Mode version 1.1.0 in Unity Editor versions 6000.0.3f1 or later. Multiplayer Play mode versions 1.0.0 and earlier are compatible with Unity version 2023.1 or later.
8+
To install the Multiplayer Play Mode package, follow these steps:
9+
10+
1. Open Unity Hub.
11+
2. Select a Project to open it.
12+
3. In the Editor's menu bar, navigate to **Window** > **Package Manager**.
13+
4. Select **Unity Registry**.
14+
5. Select the **Multiplayer Play Mode** package.
15+
6. Select **Install**.
16+
17+
## Next steps
18+
19+
You can now access and configure your [Virtual Players](../virtual-players) and their [tags](../player-tags).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
id: mtt-terms
3+
title: Multiplayer Networking Terminology
4+
---
5+
6+
The following are essential, high-level terms used in multiplayer networking and Netcode for GameObjects:
7+
8+
import MTTterms from '/static/shared/_terminology.md';
9+
10+
<MTTterms/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
id: player-tags-attach
3+
title: Attach tags to a Player
4+
description: Learn how to attach tags to a Player in Multiplayer Play Mode.
5+
---
6+
7+
To assign one or more [tags](../../player-tags) to any Player, do the following:
8+
9+
1. Open the Multiplayer Play mode window (**Window** > **Multiplayer Play Mode**).
10+
2. Expand the **Tags** dropdown for a Player or the main Editor Player.
11+
3. Select **+ Create Tag**.
12+
4. In the Project Settings window that appears, select the **Add** (**+**) icon.
13+
5. In the New tag field that appears, type a name for your tag.
14+
6. Select **Save**.
15+
7. In the Multiplayer Play Mode window, expand the **Tags** dropdown.
16+
8. Select the tag you just created.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
id: player-tags-configure
3+
title: Configure tags
4+
description: Set up tags to use them to configure the player actions.
5+
---
6+
7+
Tags don't do anything until you configure them. To configure a tag, do the following:
8+
9+
1. Use `CurrentPlayer.ReadOnlyTags()` to target the tag in a script.
10+
2. Attach the script to a [NetworkObject](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkobject/), for example, the **Player**.
11+
12+
Use the following tag examples as guides for your own scripts:
13+
14+
- [For a **Player** to run as a server, client, or host](../target-instance)
15+
- [To automatically assign a **Player** to a team](../target-team)
16+
- [To simulate network conditions](../target-network)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
id: player-tags-create
3+
title: Create a tag
4+
description: Use these steps to create tags to configure the player actions in Multiplayer Play Mode.
5+
---
6+
7+
To create a tag, perform the following actions:
8+
9+
1. To open the Multiplayer Play mode window, navigate to **Window** > **Multiplayer Play Mode**.
10+
2. Expand the Tags dropdown for a Player or the main Editor Player.
11+
3. Select ![plus sign](/img/add.png) Create Tag.
12+
4. Name the tag.
13+
5. Select **Save**. The new tag is automatically added to the local project directory in `...Projects\[example-project-name]\ProjectSettings\VirtualProjectsConfig.json`.
14+
6. The new tag also appears under the **Player Tags** section of the **Multiplayer Play Mode** window and in the dropdown menu for the **Tag** option of each **Player**.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
id: player-tags
3+
title: Information about tags
4+
description: Learn how to use tags to configure Player actions in Multiplayer Play Mode.
5+
---
6+
7+
Tags are similar to launch arguments for Players (both the main Editor Player and Virtual Players) that you can use to configure Players to behave in a specific way. For example:
8+
9+
- Run as a client, server, or host automatically
10+
- Automatically run as a member of a specific team (for example, “Red Team” or “Blue Team”)
11+
- Move faster or slower to simulate their network connection
12+
13+
You can assign multiple tags to a Player.
14+
15+
<!--
16+
<div className="table-columns-plain" >
17+
| Page | Description |
18+
</div>
19+
-->
20+
21+
|**Page** |**Description**|
22+
|-|-|
23+
|[Create tag](../player-tags/player-tags-create)| Learn how to create tags in code.|
24+
|[Configure tag](../player-tags/player-tags-configure)| Learn how to set up tags to work in your project|
25+
|[Attach a tag to a Player](../player-tags/player-tags-attach)| Learn how to assign tags to a specific Player.|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
id: target-instance
3+
title: Use tags to run a player as a server, client, or host
4+
description: This example shows how you can use Netcode for GameObjects to run a Player as a server, client, or host in Multiplayer Play Mode.
5+
---
6+
7+
This example explains how to target tags in your game scripts with `CurrentPlayer.ReadOnlyTags()`. You can place these scripts where you want, but you must attach the scripts to a [NetworkObject](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkobject/) (such as the **Player**).
8+
9+
You can also use the dedicated server package to set a tag to server, client, or host. For more information, refer to [Use Multiplayer Play Mode with a Dedicated Server](../dedicated-server/play-mode-dedicated-server.md).
10+
11+
## Set a tag to server, client, or host in a script
12+
13+
The following script uses the Netcode for GameObjects [NetworkManager](https://docs-multiplayer.unity3d.com/netcode/current/components/networkmanager/) to automatically connect the Virtual Player as a server, client, or host based on their tag. A Player with the `Server` tag automatically runs as a server, and a Player with the `Client` tag automatically runs as a client.
14+
15+
:::important
16+
This example uses the `Contains` method, which is case-sensitive by default. To make it case-insensitive, pass the `System.StringComparison.CurrentCultureIgnoreCase` method.
17+
:::
18+
19+
:::note
20+
This example uses [Netcode for GameObjects](https://docs-multiplayer.unity3d.com/netcode/current/about/).
21+
:::
22+
23+
```csharp
24+
using Unity.Netcode;
25+
using UnityEngine;
26+
using Unity.Multiplayer.Playmode;
27+
28+
/// A MonoBehaviour to automatically start Netcode for GameObjects
29+
/// clients, hosts, and servers
30+
public class MppmConnect : MonoBehaviour
31+
{
32+
void Start()
33+
{
34+
var mppmTag = CurrentPlayer.ReadOnlyTags();
35+
var networkManager = NetworkManager.Singleton;
36+
if (mppmTag.Contains("Server"))
37+
{
38+
networkManager.StartServer();
39+
}
40+
else if (mppmTag.Contains("Host"))
41+
{
42+
networkManager.StartHost();
43+
}
44+
else if (mppmTag.Contains("Client"))
45+
{
46+
networkManager.StartClient();
47+
}
48+
}
49+
}
50+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
id: target-network
3+
title: Configure a Player to simulate different network connections example
4+
description: This example shows how you can use the Network Simulator and Players to test different network connections in Multiplayer Play Mode.
5+
---
6+
7+
The logic in the following example checks if the tag has a string rather than if it’s equal to a string to allow for more flexibility with the name of the tag. You can change this logic so that it checks for an exact match.
8+
9+
## Simulate network conditions
10+
11+
This example script uses the Network Simulation Presets from the [Multiplayer Tools package](https://docs-multiplayer.unity3d.com/tools/current/install-tools/) to automatically simulate a fast or slow network based on the tag. A Player with the `FastNetwork` tag simulates a common [Home Broadband](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator/#home-broadband-connections) connection, and a Player with the `SlowNetwork` tag simulates a [Mobile 2.5G](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator/#mobile-25g) connection.
12+
13+
:::note
14+
This example uses the [Network Simulator](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator/) tool from the `com.unity.multiplayer.tools` package.
15+
:::
16+
17+
```csharp
18+
using System.Collections;
19+
using System.Collections.Generic;
20+
using UnityEngine;
21+
using Unity.Multiplayer.Playmode;
22+
using Unity.Multiplayer.Tools.NetworkSimulator.Runtime;
23+
24+
public class NetworkSimulation : MonoBehaviour
25+
{
26+
void Start()
27+
{
28+
var networkSimulator = GetComponent<NetworkSimulator>() ??
29+
gameObject.AddComponent<NetworkSimulator>();
30+
31+
var connectionPreset = NetworkSimulatorPresets.None;
32+
if (CurrentPlayer.ReadOnlyTags() == "FastNetwork")
33+
{
34+
connectionPreset = NetworkSimulatorPresets.HomeBroadband;
35+
}
36+
else if (CurrentPlayer.ReadOnlyTags() == "SlowNetwork")
37+
{
38+
connectionPreset = NetworkSimulatorPresets.Mobile2_5G;
39+
}
40+
41+
networkSimulator.ConnectionPreset = connectionPreset;
42+
}
43+
}
44+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
id: target-team
3+
title: Use tags to assign a player to a team
4+
description: Automatically assign Players to different teams in Multiplayer Play Mode.
5+
---
6+
7+
The logic in the following example checks if the tag has a string rather than if it’s equal to a string to allow for more flexibility with the name of the tag. You can change this logic so that it checks for an exact match.
8+
9+
:::important
10+
The following example uses the `Contains` method, which is case-sensitive by default. You can make it case-insensitive by passing the `System.StringComparison.CurrentCultureIgnoreCase` method.
11+
:::
12+
13+
## Automatically assign a Player to a team
14+
15+
The following script automatically sets a [NetworkVariable](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkvariable/) called `Team` based on the tag.
16+
17+
A Player with a `Red` tag automatically sets the `Team` NetworkVariable to `Red`. A Player with a `Blue` tag automatically sets the `Team` NetworkVariable to `Blue`.
18+
19+
```csharp
20+
using Unity.Netcode;
21+
using UnityEngine;
22+
using Unity.Multiplayer.Playmode;
23+
24+
public enum Team { Blue, Red, }
25+
26+
/// A player with a team that is automatically assigned
27+
/// based on the tag of the client that owns them
28+
public class Player : NetworkBehaviour
29+
{
30+
public NetworkVariable<Team> team = new (writePerm: NetworkVariableWritePermission.Owner);
31+
32+
void Start()
33+
{
34+
var localClientId = NetworkManager.Singleton.LocalClientId;
35+
if (!team.CanClientWrite(localClientId))
36+
{
37+
return;
38+
}
39+
var mppmTag = CurrentPlayer.ReadOnlyTags();
40+
if (mppmTag.Contains("Blue"))
41+
{
42+
team.Value = Team.Blue;
43+
}
44+
if (mppmTag.Contains("Red"))
45+
{
46+
team.Value = Team.Red;
47+
}
48+
}
49+
}
50+
```

0 commit comments

Comments
 (0)