Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Commit 732cea7

Browse files
jabbacakesVic-CooperNoelStephensUnityfernando-cortezamanda-butler-unity
authored
Develop into main (#1379)
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]>
1 parent c609a3d commit 732cea7

File tree

6 files changed

+69
-46
lines changed

6 files changed

+69
-46
lines changed

docs/basics/playerobjects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ To find your own player object just pass `NetworkManager.Singleton.LocalClientId
9999
- [NetworkManager](../components/networkmanager.md)
100100
- [Distributed authority topologies](../terms-concepts/distributed-authority.md)
101101
- [Client-server topologies](../terms-concepts/client-server.md)
102-
- [Object spawning](objectspawning.md)
102+
- [Object spawning](object-spawning.md)

docs/learn/bitesize/bitesize-introduction.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ title: About Bitesize samples
66
The Bitesize Samples repository provides a series of sample code as modules to use in your games and better understand Netcode for GameObjects (Netcode).
77

88
* [Multiplayer Use Cases](bitesize-usecases.md) - Learn more about core Netcode For GameObjects (Netcode) features through practical examples and In-Editor tutorials.
9-
* [2D Space Shooter Sample](bitesize-spaceshooter.md) - Learn more about physics movement and status effects using Netcode `NetworkVariables` and `ObjectPooling`.
10-
* [Invaders Sample](bitesize-invaders.md) - Learn more about game flow, modes, unconventional movement networked, and a shared timer.
11-
* [Client Driven Sample](bitesize-clientdriven.md) - Learn more about Client driven movements, networked physics, spawning vs statically placed objects, object reparenting.
12-
* [Dynamic Addressables Network Prefabs](bitesize-dynamicprefabs.md) - Learn more about the dynamic prefab system, which allows us to add new spawnable prefabs at runtime.
9+
* [2D Space Shooter](bitesize-spaceshooter.md) - Learn more about physics movement and status effects using Netcode `NetworkVariables` and `ObjectPooling`.
10+
* [Invaders](bitesize-invaders.md) - Learn more about game flow, modes, unconventional movement networked, and a shared timer.
11+
* [Client Driven](bitesize-clientdriven.md) - Learn more about Client driven movements, networked physics, spawning vs statically placed objects, object reparenting.
12+
* [Dynamic Addressables Network Prefabs](bitesize-dynamicprefabs.md) - Learn more about the dynamic prefab system, which allows you to add new spawnable prefabs at runtime.
13+
* [Distributed Authority Social Hub](bitesize-socialhub.md) - Learn how to use features of distributed authority like host migration and NetworkObject ownership transfer.
1314

1415
## Requirements
1516

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
id: bitesize-socialhub
3+
title: Distributed Authority Social Hub sample
4+
description: Learn about the scenes in the Distributed Authority Social Hub sample.
5+
---
6+
7+
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.
8+
9+
Within Social Hub, you can explore Distributed Authority in a sandbox-like environment. You can:
10+
11+
- Automatically redistribute ownership of NetworkObjects across connected clients
12+
- Experience responsive gameplay through client-side NetworkObject spawning and deferred NetworkObject despawning
13+
- Transfer ownership of NetworkObjects with variable ownership flags
14+
- Host migration of a networked game session
15+
16+
## Prerequisites
17+
18+
Social Hub uses services from Unity Gaming Services to facilitate connectivity between players. To use these services inside your project, you must:
19+
20+
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.
21+
2. Register your Unity project with that organization's cloud ID.
22+
23+
## The Bootstrap scene
24+
25+
This is the entry point to the sample. After the Bootstrap scene loads, the MainMenu scene appears.
26+
27+
**Note**: Be sure you have registered the project with a cloud ID.
28+
29+
## The MainMenu scene
30+
31+
To create or join an existing game:
32+
33+
1. Enter a player name and a session name.
34+
2. Select **Start**.
35+
36+
A successful load indicates that you have correctly registered your project with a cloud ID.
37+
38+
## The HubScene_TownMarket scene
39+
40+
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.
41+
42+
A client has authority over its player NetworkObject. Therefore, the movement, animations, and interactions that a client performs are client-authoritative.
43+
44+
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.
45+
46+
## Additional resources
47+
48+
- Get help and ask questions on [Multiplayer Discussions](https://discussions.unity.com/lists/multiplayer).
49+
- Join the community of Multiplayer creators on the [Multiplayer Networking Discord](https://discord.gg/unity-multiplayer-network).
50+
- [Request a feature or report a bug](https://github.com/Unity-Technologies/com.unity.multiplayer.samples.bitesize/issues/new/choose).

docs/learn/distributed-authority-quick-start.md

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -180,49 +180,25 @@ public class PlayerCubeControllerEditor : NetworkTransformEditor
180180
private SerializedProperty m_Speed;
181181
private SerializedProperty m_ApplyVerticalInputToZAxis;
182182

183-
184183
public override void OnEnable()
185184
{
186185
m_Speed = serializedObject.FindProperty(nameof(PlayerCubeController.Speed));
187186
m_ApplyVerticalInputToZAxis = serializedObject.FindProperty(nameof(PlayerCubeController.ApplyVerticalInputToZAxis));
188187
base.OnEnable();
189188
}
190189

190+
private void DisplayPlayerCubeControllerProperties()
191+
{
192+
EditorGUILayout.PropertyField(m_Speed);
193+
EditorGUILayout.PropertyField(m_ApplyVerticalInputToZAxis);
194+
}
191195

192196
public override void OnInspectorGUI()
193197
{
194198
var playerCubeController = target as PlayerCubeController;
195-
196-
197-
playerCubeController.PlayerCubeControllerPropertiesVisible = EditorGUILayout.BeginFoldoutHeaderGroup(playerCubeController.PlayerCubeControllerPropertiesVisible, $"{nameof(PlayerCubeController)} Properties");
198-
if (playerCubeController.PlayerCubeControllerPropertiesVisible)
199-
{
200-
EditorGUILayout.PropertyField(m_Speed);
201-
EditorGUILayout.PropertyField(m_ApplyVerticalInputToZAxis);
202-
}
203-
EditorGUILayout.EndFoldoutHeaderGroup();
204-
205-
206-
EditorGUILayout.Space();
207-
208-
209-
playerCubeController.NetworkTransformPropertiesVisible = EditorGUILayout.BeginFoldoutHeaderGroup(playerCubeController.NetworkTransformPropertiesVisible, $"{nameof(NetworkTransform)} Properties");
210-
if (playerCubeController.NetworkTransformPropertiesVisible)
211-
{
212-
// End the header group prior to invoking the base OnInspectorGUID in order to avoid nested
213-
// foldout groups.
214-
EditorGUILayout.EndFoldoutHeaderGroup();
215-
// If NetworkTransform properties are visible, then both the properties any modified properties
216-
// will be applied.
217-
base.OnInspectorGUI();
218-
}
219-
else
220-
{
221-
// End the header group
222-
EditorGUILayout.EndFoldoutHeaderGroup();
223-
// If NetworkTransform properties are not visible, then make sure we apply any modified properties.
224-
serializedObject.ApplyModifiedProperties();
225-
}
199+
void SetExpanded(bool expanded) { playerCubeController.PlayerCubeControllerPropertiesVisible = expanded; };
200+
DrawFoldOutGroup<PlayerCubeController>(playerCubeController.GetType(), DisplayPlayerCubeControllerProperties, playerCubeController.PlayerCubeControllerPropertiesVisible, SetExpanded);
201+
base.OnInspectorGUI();
226202
}
227203
}
228204
#endif
@@ -235,17 +211,11 @@ public class PlayerCubeController : NetworkTransform
235211
// within the inspector view will be saved and restored the next time the
236212
// asset/prefab is viewed.
237213
public bool PlayerCubeControllerPropertiesVisible;
238-
public bool NetworkTransformPropertiesVisible;
239214
#endif
240-
241-
242215
public float Speed = 10;
243216
public bool ApplyVerticalInputToZAxis;
244-
245-
246217
private Vector3 m_Motion;
247218

248-
249219
private void Update()
250220
{
251221
// If not spawned or we don't have authority, then don't update
@@ -254,12 +224,10 @@ public class PlayerCubeController : NetworkTransform
254224
return;
255225
}
256226

257-
258227
// Handle acquiring and applying player input
259228
m_Motion = Vector3.zero;
260229
m_Motion.x = Input.GetAxis("Horizontal");
261230

262-
263231
// Determine whether the vertical input is applied to the Y or Z axis
264232
if (!ApplyVerticalInputToZAxis)
265233
{
@@ -270,7 +238,6 @@ public class PlayerCubeController : NetworkTransform
270238
m_Motion.z = Input.GetAxis("Vertical");
271239
}
272240

273-
274241
// If there is any player input magnitude, then apply that amount of
275242
// motion to the transform
276243
if (m_Motion.magnitude > 0)

docs/terms-concepts/distributed-authority.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ For more information about how distributed authority works in Netcode for GameOb
5050
- [Race conditions](../basics/race-conditions.md)
5151
- [Spawning synchronization](../basics/spawning-synchronization.md)
5252
- [Deferred despawning](../basics/deferred-despawning.md)
53+
- [Distributed Authority Social Hub sample](../learn/bitesize/bitesize-socialhub.md)

sidebars.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ module.exports = {
578578
"type": "doc",
579579
"id": "learn/bitesize/bitesize-dynamicPrefabs"
580580
},
581+
{
582+
"type": "doc",
583+
"id": "learn/bitesize/bitesize-socialhub"
584+
},
581585
]
582586
},
583587
{

0 commit comments

Comments
 (0)