From 7da019d07780092873d230e45a35423d8bbd7a1a Mon Sep 17 00:00:00 2001 From: Vladislav vakuor Date: Sun, 29 Oct 2023 16:52:14 +0300 Subject: [PATCH 1/2] fix authority in case when in host mode --- Assets/Mirror/Core/NetworkBehaviour.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Core/NetworkBehaviour.cs b/Assets/Mirror/Core/NetworkBehaviour.cs index affca80707e..6570af48237 100644 --- a/Assets/Mirror/Core/NetworkBehaviour.cs +++ b/Assets/Mirror/Core/NetworkBehaviour.cs @@ -85,9 +85,8 @@ public abstract class NetworkBehaviour : MonoBehaviour // also note that this is a per-NetworkBehaviour flag. // another component may not be client authoritative, etc. public bool authority => - isClient - ? syncDirection == SyncDirection.ClientToServer && isOwned - : syncDirection == SyncDirection.ServerToClient; + isServer && syncDirection == SyncDirection.ServerToClient || + isClient && syncDirection == SyncDirection.ClientToServer && isOwned; /// The unique network Id of this object (unique at runtime). public uint netId => netIdentity.netId; From 54458715d61f7ec425c687c3acb07d21d6ee2e18 Mon Sep 17 00:00:00 2001 From: Vladislav vakuor Date: Sun, 29 Oct 2023 16:52:54 +0300 Subject: [PATCH 2/2] Add a comment on authority change --- Assets/Mirror/Core/NetworkBehaviour.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/Mirror/Core/NetworkBehaviour.cs b/Assets/Mirror/Core/NetworkBehaviour.cs index 6570af48237..7ed8876a51d 100644 --- a/Assets/Mirror/Core/NetworkBehaviour.cs +++ b/Assets/Mirror/Core/NetworkBehaviour.cs @@ -84,6 +84,11 @@ public abstract class NetworkBehaviour : MonoBehaviour // // also note that this is a per-NetworkBehaviour flag. // another component may not be client authoritative, etc. + // + // checking isServer firstly in case we are in host mode + // otherwise checking isClient && isOwned + // otherwise no authority + // fixes: https://github.com/MirrorNetworking/Mirror/issues/3529 public bool authority => isServer && syncDirection == SyncDirection.ServerToClient || isClient && syncDirection == SyncDirection.ClientToServer && isOwned;