com.unity.netcode.gameobjects@2.0.0-pre.1
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Additional documentation and release notes are available at [Multiplayer Documentation](https://docs-multiplayer.unity3d.com). ## [2.0.0-pre.1] - 2024-06-17 ### Added - Added event `NetworkManager.OnSessionOwnerPromoted` that is invoked when a new session owner promotion occurs. (#2948) - Added `NetworkRigidBodyBase.GetLinearVelocity` and `NetworkRigidBodyBase.SetLinearVelocity` convenience/helper methods. (#2948) - Added `NetworkRigidBodyBase.GetAngularVelocity` and `NetworkRigidBodyBase.SetAngularVelocity` convenience/helper methods. (#2948) ### Fixed - Fixed issue when `NetworkTransform` half float precision is enabled and ownership changes the current base position was not being synchronized. (#2948) - Fixed issue where `OnClientConnected` not being invoked on the session owner when connecting to a new distributed authority session. (#2948) - Fixed issue where Rigidbody micro-motion (i.e. relatively small velocities) would result in non-authority instances slightly stuttering as the body would come to a rest (i.e. no motion). Now, the threshold value can increase at higher velocities and can decrease slightly below the provided threshold to account for this. (#2948) ### Changed - Changed the client's owned objects is now returned (`NetworkClient` and `NetworkSpawnManager`) as an array as opposed to a list for performance purposes. (#2948) - Changed `NetworkTransfrom.TryCommitTransformToServer` to be internal as it will be removed by the final 2.0.0 release. (#2948) - Changed `NetworkTransformEditor.OnEnable` to a virtual method to be able to customize a `NetworkTransform` derived class by creating a derived editor control from `NetworkTransformEditor`. (#2948)
This commit is contained in:
@@ -36,17 +36,13 @@ namespace Unity.Netcode
|
||||
|
||||
#pragma warning restore IDE1006 // restore naming rule violation check
|
||||
|
||||
internal static bool IsDistributedAuthority;
|
||||
|
||||
/// <summary>
|
||||
/// Distributed Authority Mode
|
||||
/// Returns true if the current session is running in distributed authority mode.
|
||||
/// </summary>
|
||||
public bool DistributedAuthorityMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return NetworkConfig.NetworkTopology == NetworkTopologyTypes.DistributedAuthority;
|
||||
}
|
||||
}
|
||||
public bool DistributedAuthorityMode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Distributed Authority Mode
|
||||
@@ -131,6 +127,18 @@ namespace Unity.Netcode
|
||||
|
||||
public ulong CurrentSessionOwner { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Delegate declaration for <see cref="OnSessionOwnerPromoted"/>
|
||||
/// </summary>
|
||||
/// <param name="sessionOwnerPromoted">the new session owner client identifier</param>
|
||||
public delegate void OnSessionOwnerPromotedDelegateHandler(ulong sessionOwnerPromoted);
|
||||
|
||||
/// <summary>
|
||||
/// Network Topology: Distributed Authority
|
||||
/// When a new session owner is promoted, this event is triggered on all connected clients
|
||||
/// </summary>
|
||||
public event OnSessionOwnerPromotedDelegateHandler OnSessionOwnerPromoted;
|
||||
|
||||
internal void SetSessionOwner(ulong sessionOwner)
|
||||
{
|
||||
var previousSessionOwner = CurrentSessionOwner;
|
||||
@@ -151,10 +159,12 @@ namespace Unity.Netcode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnSessionOwnerPromoted?.Invoke(sessionOwner);
|
||||
}
|
||||
|
||||
// TODO: Make this internal after testing
|
||||
public void PromoteSessionOwner(ulong clientId)
|
||||
internal void PromoteSessionOwner(ulong clientId)
|
||||
{
|
||||
if (!DistributedAuthorityMode)
|
||||
{
|
||||
@@ -217,12 +227,27 @@ namespace Unity.Netcode
|
||||
#endif
|
||||
}
|
||||
|
||||
private void UpdateTopology()
|
||||
{
|
||||
var transportTopology = IsListening ? NetworkConfig.NetworkTransport.CurrentTopology() : NetworkConfig.NetworkTopology;
|
||||
if (transportTopology != NetworkConfig.NetworkTopology)
|
||||
{
|
||||
NetworkLog.LogErrorServer($"[Topology Mismatch] Transport detected an issue with the topology ({transportTopology} | {NetworkConfig.NetworkTopology}) usage or setting! Disconnecting from session.");
|
||||
Shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
IsDistributedAuthority = DistributedAuthorityMode = transportTopology == NetworkTopologyTypes.DistributedAuthority;
|
||||
}
|
||||
}
|
||||
|
||||
public void NetworkUpdate(NetworkUpdateStage updateStage)
|
||||
{
|
||||
switch (updateStage)
|
||||
{
|
||||
case NetworkUpdateStage.EarlyUpdate:
|
||||
{
|
||||
UpdateTopology();
|
||||
ConnectionManager.ProcessPendingApprovals();
|
||||
ConnectionManager.PollAndHandleNetworkEvents();
|
||||
|
||||
@@ -1012,6 +1037,8 @@ namespace Unity.Netcode
|
||||
#endif
|
||||
NetworkTransformUpdate.Clear();
|
||||
|
||||
UpdateTopology();
|
||||
|
||||
//DANGOEXP TODO: Remove this before finalizing the experimental release
|
||||
NetworkConfig.AutoSpawnPlayerPrefabClientSide = DistributedAuthorityMode;
|
||||
|
||||
@@ -1191,6 +1218,17 @@ namespace Unity.Netcode
|
||||
{
|
||||
SpawnManager.ServerSpawnSceneObjectsOnStartSweep();
|
||||
|
||||
// Notify the server that all in-scnee placed NetworkObjects are spawned at this time.
|
||||
foreach (var networkObject in SpawnManager.SpawnedObjectsList)
|
||||
{
|
||||
networkObject.InternalInSceneNetworkObjectsSpawned();
|
||||
}
|
||||
|
||||
// Notify the server that everything should be synchronized/spawned at this time.
|
||||
foreach (var networkObject in SpawnManager.SpawnedObjectsList)
|
||||
{
|
||||
networkObject.InternalNetworkSessionSynchronized();
|
||||
}
|
||||
OnServerStarted?.Invoke();
|
||||
ConnectionManager.LocalClient.IsApproved = true;
|
||||
return true;
|
||||
@@ -1337,6 +1375,17 @@ namespace Unity.Netcode
|
||||
}
|
||||
|
||||
SpawnManager.ServerSpawnSceneObjectsOnStartSweep();
|
||||
// Notify the host that all in-scnee placed NetworkObjects are spawned at this time.
|
||||
foreach (var networkObject in SpawnManager.SpawnedObjectsList)
|
||||
{
|
||||
networkObject.InternalInSceneNetworkObjectsSpawned();
|
||||
}
|
||||
|
||||
// Notify the host that everything should be synchronized/spawned at this time.
|
||||
foreach (var networkObject in SpawnManager.SpawnedObjectsList)
|
||||
{
|
||||
networkObject.InternalNetworkSessionSynchronized();
|
||||
}
|
||||
|
||||
OnServerStarted?.Invoke();
|
||||
OnClientStarted?.Invoke();
|
||||
|
||||
Reference in New Issue
Block a user