diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs index c667af47db..05df0eabc0 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs @@ -390,7 +390,7 @@ private void CheckForInScenePlaced() /// Defaults to true, determines whether the will be destroyed. public void DeferDespawn(int tickOffset, bool destroy = true) { - // Ensure we log the DAMode message first as locking ownership is not allowed if not DA so the DA message is the most relevant. + // The DAMode message is logged first, as ownership locking isn’t allowed when not in DAMode, making it the most relevant message. if (!NetworkManager.DistributedAuthorityMode) { if (NetworkManager.LogLevel <= LogLevel.Error) @@ -606,7 +606,7 @@ internal void RemoveOwnershipExtended(OwnershipStatusExtended extended) /// true or false depending upon lock operation's success public bool SetOwnershipLock(bool lockOwnership = true) { - // Ensure we log the DAMode message first as locking ownership is not allowed if not DA so the DA message is the most relevant. + // The DAMode message is logged first, as ownership locking isn’t allowed when not in DAMode, making it the most relevant message. if (!NetworkManager.DistributedAuthorityMode) { if (NetworkManager.LogLevel <= LogLevel.Error) @@ -1154,8 +1154,11 @@ public bool HasOwnershipStatus(OwnershipStatus status) [MethodImpl(MethodImplOptions.AggressiveInlining)] private bool InternalHasAuthority() { - var networkManager = NetworkManager; - return networkManager.DistributedAuthorityMode ? OwnerClientId == networkManager.LocalClientId : networkManager.IsServer; + if (!IsSpawned) + { + return false; + } + return NetworkManagerOwner.DistributedAuthorityMode ? OwnerClientId == NetworkManagerOwner.LocalClientId : NetworkManagerOwner.IsServer; } /// @@ -3541,7 +3544,7 @@ internal void SceneChangedUpdate(Scene scene, bool notify = false) OnMigratedToNewScene?.Invoke(); // Only the authority side will notify clients of non-parented NetworkObject scene changes - if (isAuthority && notify && !transform.parent) + if (isAuthority && notify && transform.parent == null) { NetworkManagerOwner.SceneManager.NotifyNetworkObjectSceneChanged(this); }