Skip to content

Commit

Permalink
Develop into main (#1379)
Browse files Browse the repository at this point in the history
Co-authored-by: Vic Cooper <[email protected]>
Co-authored-by: Vic Cooper <[email protected]>
Co-authored-by: Noel Stephens <[email protected]>
Co-authored-by: Fernando Cortez <[email protected]>
Co-authored-by: amanda-butler-unity <[email protected]>
  • Loading branch information
6 people authored Nov 14, 2024
1 parent c609a3d commit 732cea7
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 46 deletions.
2 changes: 1 addition & 1 deletion docs/basics/playerobjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 5 additions & 4 deletions docs/learn/bitesize/bitesize-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
50 changes: 50 additions & 0 deletions docs/learn/bitesize/bitesize-socialhub.md
Original file line number Diff line number Diff line change
@@ -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).
49 changes: 8 additions & 41 deletions docs/learn/distributed-authority-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,49 +180,25 @@ public class PlayerCubeControllerEditor : NetworkTransformEditor
private SerializedProperty m_Speed;
private SerializedProperty m_ApplyVerticalInputToZAxis;


public override void OnEnable()
{
m_Speed = serializedObject.FindProperty(nameof(PlayerCubeController.Speed));
m_ApplyVerticalInputToZAxis = serializedObject.FindProperty(nameof(PlayerCubeController.ApplyVerticalInputToZAxis));
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>(playerCubeController.GetType(), DisplayPlayerCubeControllerProperties, playerCubeController.PlayerCubeControllerPropertiesVisible, SetExpanded);
base.OnInspectorGUI();
}
}
#endif
Expand All @@ -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
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/terms-concepts/distributed-authority.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 4 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ module.exports = {
"type": "doc",
"id": "learn/bitesize/bitesize-dynamicPrefabs"
},
{
"type": "doc",
"id": "learn/bitesize/bitesize-socialhub"
},
]
},
{
Expand Down

0 comments on commit 732cea7

Please sign in to comment.