From b43c35df5ea857ab3e33fb2b3632972bb485d557 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Tue, 15 Apr 2025 14:18:58 -0500 Subject: [PATCH 1/2] fix Reverting some of the opinionated restrictions to permissions with in-scene placed NetworkObjects. Matching the DAHost redistribution logic to follow that of the rust servers when a client disconnects. --- .../Runtime/Connection/NetworkConnectionManager.cs | 11 ++++------- .../Runtime/Core/NetworkObject.cs | 9 --------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs b/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs index dbdff3ca2b..59a187a5fc 100644 --- a/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs @@ -1195,16 +1195,13 @@ internal void OnClientDisconnectFromServer(ulong clientId) } else if (!NetworkManager.ShutdownInProgress) { - // DANGO-TODO: We will want to match how the CMB service handles this. For now, we just try to evenly distribute - // ownership. - // NOTE: All of the below code only handles ownership transfer. + // NOTE: All of the below code only handles ownership transfer // For client-server, we just remove the ownership. - // For distributed authority, we need to change ownership based on parenting + // For distributed authority (DAHost only), we only transfer objects that are not parented or belong to the session owner. + // Rust server handles the object redistribution on its end. if (NetworkManager.DistributedAuthorityMode) { - // Only NetworkObjects that have the OwnershipStatus.Distributable flag set and are not OwnershipSessionOwner are distributed. - // If the object has a parent - skip it for now, it will be distributed when its root parent is distributed. - if (!ownedObject.IsOwnershipDistributable || ownedObject.IsOwnershipSessionOwner || ownedObject.GetCachedParent()) + if (ownedObject.IsOwnershipSessionOwner || ownedObject.GetCachedParent()) { continue; } diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs index 502ffefcb6..64c8e96076 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs @@ -325,15 +325,6 @@ private void CheckForInScenePlaced() // Default scene migration synchronization to false for in-scene placed NetworkObjects SceneMigrationSynchronization = false; - - // Root In-scene placed NetworkObjects have to either have the SessionOwner or Distributable permission flag set. - if (transform.parent == null) - { - if (!Ownership.HasFlag(OwnershipStatus.SessionOwner) && !Ownership.HasFlag(OwnershipStatus.Distributable)) - { - Ownership |= OwnershipStatus.Distributable; - } - } } } #endif // UNITY_EDITOR From 8d80f5efe92ddf9cf2aa0e836c483e32c614275c Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Tue, 15 Apr 2025 14:42:58 -0500 Subject: [PATCH 2/2] update Adding changelog entry. --- com.unity.netcode.gameobjects/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md index fab2e97f48..065f0a09ea 100644 --- a/com.unity.netcode.gameobjects/CHANGELOG.md +++ b/com.unity.netcode.gameobjects/CHANGELOG.md @@ -13,6 +13,7 @@ Additional documentation and release notes are available at [Multiplayer Documen ### Fixed +- Fixed issue where root level in-scene placed `NetworkObject`s would only allow the ownership permission to be no less than distributable or sessionowner. (#3407) ### Changed