From 3e400cc4a941ae8a2f590901120348642f2fba49 Mon Sep 17 00:00:00 2001 From: Vic Cooper <63712500+Vic-Cooper@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:59:04 +0100 Subject: [PATCH 1/3] Merge develop into main (#1371) Co-authored-by: Amy Reeve --- docs/learn/bossroom/getting-started-boss-room.md | 13 +++++++------ docusaurus.config.js | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/learn/bossroom/getting-started-boss-room.md b/docs/learn/bossroom/getting-started-boss-room.md index 6266f5d30..52a1a2f0f 100644 --- a/docs/learn/bossroom/getting-started-boss-room.md +++ b/docs/learn/bossroom/getting-started-boss-room.md @@ -28,10 +28,9 @@ Join the multiplayer community on the Unity [Discord](https://discord.gg/mNgM2XR ### Contents and quick links -- [Contents and quick links](#contents-and-quick-links) - [Boss Room Overview](#boss-room-overview) -- [Getting the project](#getting-the-project) - - [Installing Git LFS to clone locally](#installing-git-lfs-to-clone-locally) +- [Install the Boss Room project](#getting-the-project) + - [Install Git LFS to clone locally](#installing-git-lfs-to-clone-locally) - [Direct download](#direct-download) - [Registering the project with Unity Gaming Services (UGS)](#registering-the-project-with-unity-gaming-services-ugs) - [Opening the project for the first time](#opening-the-project-for-the-first-time) @@ -66,11 +65,13 @@ This repository also has a [Utilities](https://github.com/Unity-Technologies/com For more information on the art in Boss Room, see [ART_NOTES.md](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop/blob/v2.2.0/Documentation/ART_NOTES.md). -### Getting the project +### Install the Boss Room project -You can get the project by downloading it directly or cloning locally. However, if you use git, you must install Git LFS. +To install the Boss Room project, download or clone it from the [com.unity.multiplayer.samples.coop](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop) repository. -#### Installing Git LFS to clone locally +**Note**: If you install the project with Git, you must install Git LFS first. + +#### Install Git LFS to clone locally Boss Room uses Git Large Files Support (LFS) to handle all large assets required locally. See [Git LFS installation options](https://github.com/git-lfs/git-lfs/wiki/Installation) for Windows and Mac instructions. This step is only needed if cloning locally. You can also just download the project which will already include large files. diff --git a/docusaurus.config.js b/docusaurus.config.js index 14310676e..5feb8bb75 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -385,7 +385,7 @@ module.exports = { lastVersion: "current", versions: { current: { - label: "1.3.0", + label: "1.3.1", path: "current", }, "1.2.0": { From c609a3ddfc6039e42bd57a7e0a1e770cd8ede21b Mon Sep 17 00:00:00 2001 From: Amy Reeve Date: Wed, 13 Nov 2024 15:51:10 +0000 Subject: [PATCH 2/3] Develop into main to publish WebGL quickstart (#1377) Co-authored-by: Vic Cooper Co-authored-by: Vic Cooper <63712500+Vic-Cooper@users.noreply.github.com> Co-authored-by: Noel Stephens --- .../distributed-authority-quick-start.md | 5 +-- docs/learn/distributed-authority-webgl.md | 39 +++++++++++++++++++ docs/terms-concepts/distributed-authority.md | 2 +- docs/tutorials/get-started-with-ngo.md | 6 +-- sidebars.js | 17 ++++++-- 5 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 docs/learn/distributed-authority-webgl.md diff --git a/docs/learn/distributed-authority-quick-start.md b/docs/learn/distributed-authority-quick-start.md index e0cf9522f..178ad6744 100644 --- a/docs/learn/distributed-authority-quick-start.md +++ b/docs/learn/distributed-authority-quick-start.md @@ -1,6 +1,6 @@ --- id: distributed-authority-quick-start -title: Distributed authority quickstart for Netcode for GameObjects +title: Distributed authority general quickstart --- Use this guide to learn how to create your first [distributed authority](../terms-concepts/distributed-authority.md) Netcode for GameObjects project. It walks you through the connection setup, including connecting to the distributed authority service, and adding basic gameplay. @@ -15,8 +15,7 @@ Before you begin, you need the following: - An active Unity account with a valid license. - The [Unity Hub](https://unity.com/download). -- A supported version of the Unity 6 Editor. - - Additional requirements information can be found here: [Netcode for GameObjects requirements](https://docs-multiplayer.unity3d.com/netcode/current/installation). +- A supported version of the Unity 6 Editor. Refer to the [Netcode for GameObjects requirements](https://docs-multiplayer.unity3d.com/netcode/current/installation). ## Project setup diff --git a/docs/learn/distributed-authority-webgl.md b/docs/learn/distributed-authority-webgl.md new file mode 100644 index 000000000..3938d4f97 --- /dev/null +++ b/docs/learn/distributed-authority-webgl.md @@ -0,0 +1,39 @@ +--- +id: distributed-authority-webgl +title: Distributed authority and WebGL quickstart +--- + +Use this guide to learn how to create your first [distributed authority](../terms-concepts/distributed-authority.md) Netcode for GameObjects WebGL project. + +This guide is intended as an addition to the [distributed authority general quickstart](distributed-authority-quick-start.md) page, which provides more details about setting up Netcode for GameObjects to use distributed authority. + +:::note Beta feature +Distributed authority is still in beta. During the beta phase, using the distributed authority service provided by the [Multiplayer Services package](https://docs.unity.com/ugs/en-us/manual/mps-sdk/manual) is free. When distributed authority is fully released, [using the service will incur a cost](https://unity.com/products/gaming-services/pricing). +::: + +## Prerequisites + +Before you begin, you need the following general requirements to use the distributed authority network topology: + +- An active Unity account with a valid license. +- The [Unity Hub](https://unity.com/download). +- A supported version of the Unity 6 Editor. Refer to the [Netcode for GameObjects requirements](https://docs-multiplayer.unity3d.com/netcode/current/installation). + - When installing the Editor, make sure to include the __WebGL Build Support_ module. + +You also need the following packages and minimum versions for a WebGL distributed authority session: + +- Netcode for GameObjects version 2.1.1+ +- Unity Transport version 2.3.0+ + - Note that you don't need to create a self-signed certificate to connect to a distributed authority session. +- Multiplayer Services version 1.0.2+ + +## Create and set up your project + +Follow the instructions on the [distributed authority general quickstart](distributed-authority-quick-start.md) page. + +## Build and run with WebGL + +1. Navigate to __File__ > __Build Profiles__ to open the __Build Profiles__ window. Select WebGL as your target platform. +1. From the __Build Profiles__ window, click __Build and Run__. + - Unity launches a small web hosting app to provide the HTTP services required to launch the WebGL application in your browser. +1. Once you have one instance of your WebGL project running, you can copy the URI from your browser and paste it into another window or tab, which creates and connects another player to the same session. diff --git a/docs/terms-concepts/distributed-authority.md b/docs/terms-concepts/distributed-authority.md index 95d37a282..44614dfce 100644 --- a/docs/terms-concepts/distributed-authority.md +++ b/docs/terms-concepts/distributed-authority.md @@ -32,7 +32,7 @@ For game designs that don't require a precise physics simulation or client predi The traditional [client-server](client-server.md) model typically includes a service relay to solve connectivity issues, notably Network Address Translation (NAT), between players across different regions and networks. This topology works well for projects that require competitive client prediction, rollback, and a centralized authority – however, it comes at the cost of added latencies when communicating state changes from one client to another. -With a distributed authority topology, a client's state change takes a single client-relative [round trip period of time (RTT)](../lagandpacketloss.md#round-trip-time-and-pings) (½ per client) to be updated on all connected clients. The distributed authority service is more efficient: messages are routed and then processed, whereas client-server topologies require messages to be processed and then, at a later time, conveyed via new messages to all connected clients. +With a distributed authority topology, a client's state change takes a single client-relative [round trip period of time (RTT)](../learn/lagandpacketloss.md#round-trip-time-and-pings) (½ per client) to be updated on all connected clients. The distributed authority service is more efficient: messages are routed and then processed, whereas client-server topologies require messages to be processed and then, at a later time, conveyed via new messages to all connected clients.

diff --git a/docs/tutorials/get-started-with-ngo.md b/docs/tutorials/get-started-with-ngo.md index 4c202e35b..193fc9f86 100644 --- a/docs/tutorials/get-started-with-ngo.md +++ b/docs/tutorials/get-started-with-ngo.md @@ -1,6 +1,6 @@ --- id: get-started-ngo -title: Client-server quickstart for Netcode for GameObjects +title: Client-server quickstart --- Use this guide to learn how to create your first [client-server](../terms-concepts/client-server.md) Netcode for GameObjects project. It walks you through creating a simple Hello World project that implements the basic features of Netcode for GameObjects. @@ -116,7 +116,7 @@ Netcode for GameObjects comes with an integrated scene management solution that Now that you have a **NetworkManager**, assigned a **PlayerPrefab**, and added your current scene to the scenes in build test, you can quickly verify everything is functioning/configured correctly via entering play mode in the Unity Editor. By starting a host, you are starting `NetworkManager` as both a server and a client at the same time. -You can test your Hello World project using the Unity Editor or a command-line helper. If you choose the latter, refer to [Create a command line helper](../tutorials/command-line-helper/). Otherwise, refer to the following instructions to test using the Unity Editor. Only the Plane appears on the server until the first client connects. Then, Netcode for GameObjects spawns a new Player prefab for each connected client; however, they overlap in the Game view. +You can test your Hello World project using the Unity Editor or a command-line helper. If you choose the latter, refer to [Create a command line helper](command-line-helper.md). Otherwise, refer to the following instructions to test using the Unity Editor. Only the Plane appears on the server until the first client connects. Then, Netcode for GameObjects spawns a new Player prefab for each connected client; however, they overlap in the Game view. 1. Select **Play** from the top of the Unity Editor to start the scene. @@ -403,7 +403,7 @@ namespace HelloWorld } ``` -#### A Review of the `HelloWorldPlayer.cs` script +#### A Review of the `HelloWorldPlayer.cs` script The `HelloWorldPlayer.cs` script adds some basic movement to the Hello World project player. Both the server player and the client player can start player movement. However, the movement occurs through the server's position NetworkVariable, which means the server player can move immediately, but the client player must request a movement from the server, wait for the server to update the position NetworkVariable, then replicate the change locally. diff --git a/sidebars.js b/sidebars.js index 38ad299a3..1dd9ad9aa 100644 --- a/sidebars.js +++ b/sidebars.js @@ -45,9 +45,20 @@ module.exports = { "id": "tutorials/get-started-ngo" }, { - "type": "doc", - "id": "learn/distributed-authority-quick-start" - }, + "collapsed": true, + "type": "category", + "label": "Distributed authority quickstart", + "items": [ + { + "type": "doc", + "id": "learn/distributed-authority-quick-start" + }, + { + "type": "doc", + "id": "learn/distributed-authority-webgl" + }, + ] + }, { "collapsed": true, "type": "category", From 732cea74ce6828c8087b689a716aee261b000e2e Mon Sep 17 00:00:00 2001 From: Amy Reeve Date: Thu, 14 Nov 2024 10:18:52 +0000 Subject: [PATCH 3/3] Develop into main (#1379) Co-authored-by: Vic Cooper Co-authored-by: Vic Cooper <63712500+Vic-Cooper@users.noreply.github.com> Co-authored-by: Noel Stephens Co-authored-by: Fernando Cortez Co-authored-by: amanda-butler-unity <96449283+amanda-butler-unity@users.noreply.github.com> --- docs/basics/playerobjects.md | 2 +- docs/learn/bitesize/bitesize-introduction.md | 9 ++-- docs/learn/bitesize/bitesize-socialhub.md | 50 +++++++++++++++++++ .../distributed-authority-quick-start.md | 49 +++--------------- docs/terms-concepts/distributed-authority.md | 1 + sidebars.js | 4 ++ 6 files changed, 69 insertions(+), 46 deletions(-) create mode 100644 docs/learn/bitesize/bitesize-socialhub.md diff --git a/docs/basics/playerobjects.md b/docs/basics/playerobjects.md index fa0439b42..db2b9dab8 100644 --- a/docs/basics/playerobjects.md +++ b/docs/basics/playerobjects.md @@ -99,4 +99,4 @@ To find your own player object just pass `NetworkManager.Singleton.LocalClientId - [NetworkManager](../components/networkmanager.md) - [Distributed authority topologies](../terms-concepts/distributed-authority.md) - [Client-server topologies](../terms-concepts/client-server.md) -- [Object spawning](objectspawning.md) +- [Object spawning](object-spawning.md) diff --git a/docs/learn/bitesize/bitesize-introduction.md b/docs/learn/bitesize/bitesize-introduction.md index f4acedded..b5dfe9dc3 100644 --- a/docs/learn/bitesize/bitesize-introduction.md +++ b/docs/learn/bitesize/bitesize-introduction.md @@ -6,10 +6,11 @@ title: About Bitesize samples The Bitesize Samples repository provides a series of sample code as modules to use in your games and better understand Netcode for GameObjects (Netcode). * [Multiplayer Use Cases](bitesize-usecases.md) - Learn more about core Netcode For GameObjects (Netcode) features through practical examples and In-Editor tutorials. -* [2D Space Shooter Sample](bitesize-spaceshooter.md) - Learn more about physics movement and status effects using Netcode `NetworkVariables` and `ObjectPooling`. -* [Invaders Sample](bitesize-invaders.md) - Learn more about game flow, modes, unconventional movement networked, and a shared timer. -* [Client Driven Sample](bitesize-clientdriven.md) - Learn more about Client driven movements, networked physics, spawning vs statically placed objects, object reparenting. -* [Dynamic Addressables Network Prefabs](bitesize-dynamicprefabs.md) - Learn more about the dynamic prefab system, which allows us to add new spawnable prefabs at runtime. +* [2D Space Shooter](bitesize-spaceshooter.md) - Learn more about physics movement and status effects using Netcode `NetworkVariables` and `ObjectPooling`. +* [Invaders](bitesize-invaders.md) - Learn more about game flow, modes, unconventional movement networked, and a shared timer. +* [Client Driven](bitesize-clientdriven.md) - Learn more about Client driven movements, networked physics, spawning vs statically placed objects, object reparenting. +* [Dynamic Addressables Network Prefabs](bitesize-dynamicprefabs.md) - Learn more about the dynamic prefab system, which allows you to add new spawnable prefabs at runtime. +* [Distributed Authority Social Hub](bitesize-socialhub.md) - Learn how to use features of distributed authority like host migration and NetworkObject ownership transfer. ## Requirements diff --git a/docs/learn/bitesize/bitesize-socialhub.md b/docs/learn/bitesize/bitesize-socialhub.md new file mode 100644 index 000000000..a4283525a --- /dev/null +++ b/docs/learn/bitesize/bitesize-socialhub.md @@ -0,0 +1,50 @@ +--- +id: bitesize-socialhub +title: Distributed Authority Social Hub sample +description: Learn about the scenes in the Distributed Authority Social Hub sample. +--- + +The [Distributed Authority Social Hub Sample](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/tree/main/Basic/DistributedAuthoritySocialHub) is a project that demonstrates Distributed Authority's features and helps you integrate Distributed Authority into your own game projects. + +Within Social Hub, you can explore Distributed Authority in a sandbox-like environment. You can: + +- Automatically redistribute ownership of NetworkObjects across connected clients +- Experience responsive gameplay through client-side NetworkObject spawning and deferred NetworkObject despawning +- Transfer ownership of NetworkObjects with variable ownership flags +- Host migration of a networked game session + +## Prerequisites + +Social Hub uses services from Unity Gaming Services to facilitate connectivity between players. To use these services inside your project, you must: + +1. [Create an organization](https://support.unity.com/hc/en-us/articles/208592876-How-do-I-create-a-new-Unity-organization) inside the Unity Dashboard. +2. Register your Unity project with that organization's cloud ID. + +## The Bootstrap scene + +This is the entry point to the sample. After the Bootstrap scene loads, the MainMenu scene appears. + +**Note**: Be sure you have registered the project with a cloud ID. + +## The MainMenu scene + +To create or join an existing game: + +1. Enter a player name and a session name. +2. Select **Start**. + +A successful load indicates that you have correctly registered your project with a cloud ID. + +## The HubScene_TownMarket scene + +This a sandbox-like environment that supports 64 players. The control model is WASD controls. Move around the level with client-authority, and use **E** to interact with crates and pots. These are NetworkObjects that you can pick up, drop, and throw. Attach one NetworkObject to another with an animated rig through the use of FixedJoints. As a client picks up a NetworkObject, authority of that NetworkObject transfers to that client. + +A client has authority over its player NetworkObject. Therefore, the movement, animations, and interactions that a client performs are client-authoritative. + +This sample inherently supports host migration out of the box. Load multiple clients, and witness the automatic distribution of ownership of NetworkObjects when the original session owner leaves the session. + +## Additional resources + +- Get help and ask questions on [Multiplayer Discussions](https://discussions.unity.com/lists/multiplayer). +- Join the community of Multiplayer creators on the [Multiplayer Networking Discord](https://discord.gg/unity-multiplayer-network). +- [Request a feature or report a bug](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/issues/new/choose). diff --git a/docs/learn/distributed-authority-quick-start.md b/docs/learn/distributed-authority-quick-start.md index 178ad6744..9f143096d 100644 --- a/docs/learn/distributed-authority-quick-start.md +++ b/docs/learn/distributed-authority-quick-start.md @@ -180,7 +180,6 @@ public class PlayerCubeControllerEditor : NetworkTransformEditor private SerializedProperty m_Speed; private SerializedProperty m_ApplyVerticalInputToZAxis; - public override void OnEnable() { m_Speed = serializedObject.FindProperty(nameof(PlayerCubeController.Speed)); @@ -188,41 +187,18 @@ public class PlayerCubeControllerEditor : NetworkTransformEditor base.OnEnable(); } + private void DisplayPlayerCubeControllerProperties() + { + EditorGUILayout.PropertyField(m_Speed); + EditorGUILayout.PropertyField(m_ApplyVerticalInputToZAxis); + } public override void OnInspectorGUI() { var playerCubeController = target as PlayerCubeController; - - - playerCubeController.PlayerCubeControllerPropertiesVisible = EditorGUILayout.BeginFoldoutHeaderGroup(playerCubeController.PlayerCubeControllerPropertiesVisible, $"{nameof(PlayerCubeController)} Properties"); - if (playerCubeController.PlayerCubeControllerPropertiesVisible) - { - EditorGUILayout.PropertyField(m_Speed); - EditorGUILayout.PropertyField(m_ApplyVerticalInputToZAxis); - } - EditorGUILayout.EndFoldoutHeaderGroup(); - - - EditorGUILayout.Space(); - - - playerCubeController.NetworkTransformPropertiesVisible = EditorGUILayout.BeginFoldoutHeaderGroup(playerCubeController.NetworkTransformPropertiesVisible, $"{nameof(NetworkTransform)} Properties"); - if (playerCubeController.NetworkTransformPropertiesVisible) - { - // End the header group prior to invoking the base OnInspectorGUID in order to avoid nested - // foldout groups. - EditorGUILayout.EndFoldoutHeaderGroup(); - // If NetworkTransform properties are visible, then both the properties any modified properties - // will be applied. - base.OnInspectorGUI(); - } - else - { - // End the header group - EditorGUILayout.EndFoldoutHeaderGroup(); - // If NetworkTransform properties are not visible, then make sure we apply any modified properties. - serializedObject.ApplyModifiedProperties(); - } + void SetExpanded(bool expanded) { playerCubeController.PlayerCubeControllerPropertiesVisible = expanded; }; + DrawFoldOutGroup(playerCubeController.GetType(), DisplayPlayerCubeControllerProperties, playerCubeController.PlayerCubeControllerPropertiesVisible, SetExpanded); + base.OnInspectorGUI(); } } #endif @@ -235,17 +211,11 @@ public class PlayerCubeController : NetworkTransform // within the inspector view will be saved and restored the next time the // asset/prefab is viewed. public bool PlayerCubeControllerPropertiesVisible; - public bool NetworkTransformPropertiesVisible; #endif - - public float Speed = 10; public bool ApplyVerticalInputToZAxis; - - private Vector3 m_Motion; - private void Update() { // If not spawned or we don't have authority, then don't update @@ -254,12 +224,10 @@ public class PlayerCubeController : NetworkTransform return; } - // Handle acquiring and applying player input m_Motion = Vector3.zero; m_Motion.x = Input.GetAxis("Horizontal"); - // Determine whether the vertical input is applied to the Y or Z axis if (!ApplyVerticalInputToZAxis) { @@ -270,7 +238,6 @@ public class PlayerCubeController : NetworkTransform m_Motion.z = Input.GetAxis("Vertical"); } - // If there is any player input magnitude, then apply that amount of // motion to the transform if (m_Motion.magnitude > 0) diff --git a/docs/terms-concepts/distributed-authority.md b/docs/terms-concepts/distributed-authority.md index 44614dfce..c898eb0d5 100644 --- a/docs/terms-concepts/distributed-authority.md +++ b/docs/terms-concepts/distributed-authority.md @@ -50,3 +50,4 @@ For more information about how distributed authority works in Netcode for GameOb - [Race conditions](../basics/race-conditions.md) - [Spawning synchronization](../basics/spawning-synchronization.md) - [Deferred despawning](../basics/deferred-despawning.md) +- [Distributed Authority Social Hub sample](../learn/bitesize/bitesize-socialhub.md) diff --git a/sidebars.js b/sidebars.js index 1dd9ad9aa..9ae218c72 100644 --- a/sidebars.js +++ b/sidebars.js @@ -578,6 +578,10 @@ module.exports = { "type": "doc", "id": "learn/bitesize/bitesize-dynamicPrefabs" }, + { + "type": "doc", + "id": "learn/bitesize/bitesize-socialhub" + }, ] }, {