Skip to content

Commit

Permalink
Merge develop into main (#1274)
Browse files Browse the repository at this point in the history
Co-authored-by: Amy Reeve <[email protected]>
Co-authored-by: Dominick <[email protected]>
Co-authored-by: Rémi MACH <[email protected]>
Co-authored-by: LagowiecDev <[email protected]>
Co-authored-by: amanda-butler-unity <[email protected]>
Co-authored-by: Noel Stephens <[email protected]>
Co-authored-by: Griffin of Innatical <[email protected]>
Co-authored-by: Christopher Pope <[email protected]>
Co-authored-by: Steve Diniro <[email protected]>
Co-authored-by: s-omeilia-unity <[email protected]>
Co-authored-by: Alex Martin <[email protected]>
Co-authored-by: Monaxys <[email protected]>
Co-authored-by: Flap27 <[email protected]>
Co-authored-by: NRTnarathip <[email protected]>
Co-authored-by: Elfi0Kuhndorf <[email protected]>
  • Loading branch information
16 people authored May 30, 2024
1 parent 624f5b0 commit f486ac4
Show file tree
Hide file tree
Showing 27 changed files with 742 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/learn/bitesize/bitesize-clientdriven.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Making movements feel responsive while staying consistent over multiple game exe
## 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 sample 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](../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#L274-L276
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
Expand All @@ -40,7 +40,7 @@ https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blo
Notice how we're checking whether that object can be picked up or not (since another player can have picked it up at the same time, creating a conflict).

```csharp reference
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/v1.2.1/Basic/ClientDriven/Assets/Scripts/ServerPlayerMove.cs#L50
https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/blob/v1.2.1/Basic/ClientDriven/Assets/Scripts/ServerPlayerMove.cs#L50-L58
```
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.

Expand Down
6 changes: 5 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,13 @@ module.exports = {
lastVersion: "current",
versions: {
current: {
label: "1.0.0",
label: "1.1.0",
path: "current",
},
"1.0.0": {
label: "1.0.0",
path: "1.0.0",
},
"0.6.0": {
label: "0.6.0",
path: "0.6.0",
Expand Down
4 changes: 4 additions & 0 deletions mppm/dedicated-server/multiplayer-role.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ description: Learn how to use the dedicated server package to assign virtual pla

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.

::: Important
To avoid errors, install the Dedicated Server package version that is the same as the Multiplayer Play mode version that exists in your project.
:::

## Set the main editor player multiplayer role

To set the role of a the main editor player, do the following:
Expand Down
9 changes: 3 additions & 6 deletions mppm/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ To begin testing your multiplayer functionality, you must first install the Mult
1. Open Unity Hub.
2. Select a Project.
3. In the Editor's menu bar, navigate to **Window** > **Package Manager**.
4. Click the plus sign ![plus sign](/img/add.png) in the Package Manager status bar.
5. Select **Install package by name...**.
6. Enter `com.unity.multiplayer.playmode` in the pop-up window.
7. Select **Add**.
8. After the download is complete, **Multiplayer Play Mode** appears under **Unity Technologies** in the **Package Manager** window.
9. To open the Multiplayer Play Mode window, navigate to **Window** > **Multiplayer Play Mode**.
4. Select **Unity Registry**.
5. Select the **Multiplayer Play Mode** package.
6. Select **Install**.

## Next steps

Expand Down
19 changes: 19 additions & 0 deletions mppm/release-notes/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ title: Release notes
description: Release notes for Multiplayer Play Mode including new features, updates, bug fixes, and known issues.
---

## [1.1.0] - 2024-04-24

### Added
- Added a new layout option to each Multiplayer Play Mode clone in projects that include the Netcode For Entities package.
- Updated the **Close** button to display a warning dialog prompt that deactivates a virtual player.
- Added the mute setting to mute specific users.
- Added a setting that changes the Asset Database refresh timeout.
- Updated the focus shortcut behavior to focus on other individual virtual player windows from inside an individual player.
- Updated the message that appears when a Symlink failure (on FAT32) happens because it isn't supported.

### Fixed
- The local clone cache clears automatically when you update the Multiplayer Play Mode package.
- Fixed a crash caused by devices set to certain regions.
- Changed the default multiplayer role of player clones to Client and Server.
- Added a minimum width for the main view of the Multiplayer Play Mode window.
- The escape key no longer closes virtual player windows on Windows devices.
- Fixed issues with heartbeat timeout.
- Removed the forward slash **/** character from tags because it's for drop-down behavior only.

## [1.0.0] - 2024-03-12

### Added
Expand Down
33 changes: 33 additions & 0 deletions mppm_versioned_docs/version-1.0.0/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: about
title: About Multiplayer Play Mode
description: Overview of Multiplayer Play Mode
---

Use Multiplayer Play Mode to test multiplayer functionality within the Unity Editor. You can simulate up to four players (the Main Editor 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.

## Multiplayer Play Mode terminology

The following have specific meaning in relation to Multiplayer Play Mode:

* Main Editor: The original instance of the project in the Unity Editor. This is the only instance with full authoring capabilities.
* 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).
* Players: All player instances, including the Main Editor Player and all Virtual Players.

## Limitations

Multiplayer Play Mode has some inherent technical limitations, specifically around [scale](#scale) and [authoring](#authoring).

### Scale

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 and three Virtual Players).

### Authoring
You can't create or change the properties of GameObjects in a Virtual Player. Instead, use the Main Editor to make changes and a Virtual Player to test multiplayer functionality. Any changes you make in Play Mode in the Main Editor reset when you exit Play Mode.
:::note
You can't access any Main Editor functionality from Virtual Players.
:::

## Performance impact

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 and each Virtual Player.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
id: multiplayer-role
title: Assign virtual players to a multiplayer role
description: Learn how to use the dedicated server package to assign virtual players to a multiplayer role.
---

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.

::: Important
To avoid errors, install the Dedicated Server package version that is the same as the Multiplayer Play mode version that exists in your project.
:::

## Set the main editor player multiplayer role

To set the role of a the main editor player, do the following:

1. Open the Multiplayer Play Mode inspector (**Multiplayer** > **Multiplayer Play Mode**).
2. In the **Main Editor Player** section, expand the **Multiplayer Role** dropdown.
3. Select the [multiplayer role](https://docs.unity3d.com/Packages/[email protected]/manual/multiplayer-roles.html) you want the main editor to use.

## Set the multiplayer role of a virtual player

To set the role of a [virtual player](../../virtual-players), do the following:

1. Open the Multiplayer Play Mode inspector (**Multiplayer** > **Multiplayer Play Mode**).
2. In the **Virtual Players** section, expand a virtual player's **Multiplayer Role** dropdown.
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 number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
id: play-mode-dedicated-server
title: Use Multiplayer Play mode with a Dedicated Server
description: Use the dedicated server package with multiplayer play mode.
---

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.

<!--
<div className="table-columns-plain" >
| Page | Description |
</div>
-->

|**Page** |**Description**|
|-|-|
|[Debug Multiplayer Play Mode](debug-mppm.md)| Learn how to use Unity Test Framework to test a project with Multiplayer Play Mode. |
18 changes: 18 additions & 0 deletions mppm_versioned_docs/version-1.0.0/install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
id: install
title: Install Multiplayer Play Mode
description: How to install Multiplayer Play Mode
---

To begin testing your multiplayer functionality, you must first install the Multiplayer Play Mode package.

1. Open Unity Hub.
2. Select a Project.
3. In the Editor's menu bar, navigate to **Window** > **Package Manager**.
4. Select **Unity Registry**.
5. Select the **Multiplayer Play Mode** package.
6. Select **Install**.

## Next steps

You can now access and configure your [Virtual Players](../virtual-players) and their [Player Tags](../player-tags).
10 changes: 10 additions & 0 deletions mppm_versioned_docs/version-1.0.0/mutliplayer-terms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
id: mtt-terms
title: Multiplayer Networking Terminology
---

The following are essential, high-level terms used in multiplayer networking and Netcode for GameObjects:

import MTTterms from '/static/shared/_terminology.md';

<MTTterms/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
id: player-tags-attach
title: Attach Player Tags to a player
description: Learn how to attach Player Tags to a player in Multiplayer Play Mode.
---

To assign one or more [Player Tags](../../player-tags) to any player, do the following:

1. Open the Multiplayer Play mode window (**Window** > **Multiplayer Play Mode**).
2. Expand the **Tags** dropdown for a Player or the Main Editor.
3. Select **+ Create Tag**.
4. In the Project Settings window that appears, select the **Add** (**+**) icon.
5. In the New Player Tag field that appears, type a name for your tag.
6. Select **Save**.
7. In the Multiplayer Play Mode window, expand the **Tags** dropdown.
8. Select the tag you just created.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
id: player-tags-configure
title: Configure Player Tags
description: Set up Player Tags to use them to configure the player actions.
---

Player Tags don't do anything until you configure them. To configure a player tag, do the following:

1. Use `CurrentPlayer.ReadOnlyTags()` to target the Player Tag in a script.
2. Attach the script to a [NetworkObject](https://docs-multiplayer.unity3d.com/netcode/current/basics/networkobject/), for example, the **Player**.

Use the following **Player Tag** examples as guides for your own scripts:

- [For a **Player** to run as a server, client, or host](../target-instance)
- [To automatically assign a **Player** to a team](../target-team)
- [To simulate network conditions](../target-network)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
id: player-tags-create
title: Create a Player Tags
description: Use these steps to create Player Tags to configure the player actions in Multiplayer Play Mode.
---

To create a **Player Tag**, perform the following actions:

1. To open the Multiplayer Play mode window, navigate to **Window** > **Multiplayer Play Mode**.
2. Expand the Tags dropdown for a Player or the Main Editor.
3. Select ![plus sign](/img/add.png) Create Tag.
4. Name the **Player Tag**.
5. Select **Save**. The new tag is automatically added to the local project directory in `...Projects\[example-project-name]\ProjectSettings\VirtualProjectsConfig.json`.
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**.
25 changes: 25 additions & 0 deletions mppm_versioned_docs/version-1.0.0/player-tags/player-tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
id: player-tags
title: Player Tags
description: Learn how to use Player Tags to configure player actions in Multiplayer Play Mode.
---

Player 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:

- Run as a client, server, or host automatically
- Automatically run as a member of a specific team (for example, “Red Team” or “Blue Team”)
- Move faster or slower to simulate their network connection

You can assign multiple tags to a player.

<!--
<div className="table-columns-plain" >
| Page | Description |
</div>
-->

|**Page** |**Description**|
|-|-|
|[Create Player Tag](../player-tags/player-tags-create)| Learn how to create player tags in code.|
|[Configure Player tag](../player-tags/player-tags-configure)| Learn how to set up player tags to work in your project|
|[Attach a Player Tag to a player](../player-tags/player-tags-attach)| Learn how to assign tags to a specific player.|
50 changes: 50 additions & 0 deletions mppm_versioned_docs/version-1.0.0/player-tags/target-instance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
id: target-instance
title: Use Player Tags to run a player as a server, client, or host
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.
---

This example explains how to target **Player 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**).

You can also use the dedicated server package to set a player 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).

## Set a player tag to server, client, or host in a script

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 Player Tag. 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.

:::important
This example uses the `Contains` method, which is case-sensitive by default. To make it case-insensitive, pass the `System.StringComparison.CurrentCultureIgnoreCase` method.
:::

:::note
This example uses [Netcode for GameObjects](https://docs-multiplayer.unity3d.com/netcode/current/about/).
:::

```csharp
using Unity.Netcode;
using UnityEngine;
using Unity.Multiplayer.Playmode;

/// A MonoBehaviour to automatically start Netcode for GameObjects
/// clients, hosts, and servers
public class MppmConnect : MonoBehaviour
{
void Start()
{
var mppmTag = CurrentPlayer.ReadOnlyTags();
var networkManager = NetworkManager.Singleton;
if (mppmTag.Contains("Server"))
{
networkManager.StartServer();
}
else if (mppmTag.Contains("Host"))
{
networkManager.StartHost();
}
else if (mppmTag.Contains("Client"))
{
networkManager.StartClient();
}
}
}
```
44 changes: 44 additions & 0 deletions mppm_versioned_docs/version-1.0.0/player-tags/target-network.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
id: target-network
title: Configure a Player to simulate different network connections example
description: This example shows how you can use the Network Simulator and Players to test different network connections in Multiplayer Play Mode.
---

The logic in the following example 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 change this logic so that it checks for an exact match.

## Simulate network conditions

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 Player Tag. A Player with the `FastNetwork` Player 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` Player Tag simulates a [Mobile 2.5G](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator/#mobile-25g) connection.

:::note
This example uses the [Network Simulator](https://docs-multiplayer.unity3d.com/tools/current/tools-network-simulator/) tool from the `com.unity.multiplayer.tools` package.
:::

```csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Multiplayer.Playmode;
using Unity.Multiplayer.Tools.NetworkSimulator.Runtime;

public class NetworkSimulation : MonoBehaviour
{
void Start()
{
var networkSimulator = GetComponent<NetworkSimulator>() ??
gameObject.AddComponent<NetworkSimulator>();

var connectionPreset = NetworkSimulatorPresets.None;
if (CurrentPlayer.ReadOnlyTags() == "FastNetwork")
{
connectionPreset = NetworkSimulatorPresets.HomeBroadband;
}
else if (CurrentPlayer.ReadOnlyTags() == "SlowNetwork")
{
connectionPreset = NetworkSimulatorPresets.Mobile2_5G;
}

networkSimulator.ConnectionPreset = connectionPreset;
}
}
```
Loading

0 comments on commit f486ac4

Please sign in to comment.