From 9bfcd1c1100f66e20a645177c6de94ac8a1ff390 Mon Sep 17 00:00:00 2001 From: mischa Date: Tue, 27 Jun 2023 12:19:55 +0800 Subject: [PATCH] fix: #3529 NPC SyncDirection 'authority' now evaluates to true on the server/host --- Assets/Mirror/Core/NetworkBehaviour.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Assets/Mirror/Core/NetworkBehaviour.cs b/Assets/Mirror/Core/NetworkBehaviour.cs index 84d0d9de09d..23a3af12fd3 100644 --- a/Assets/Mirror/Core/NetworkBehaviour.cs +++ b/Assets/Mirror/Core/NetworkBehaviour.cs @@ -85,9 +85,12 @@ 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; + // check isServer instead of isClient, which covers host mode too. + // otherwise host mode would only have authority if ClientToServer. + // fixes: https://github.com/MirrorNetworking/Mirror/issues/3529 + isServer + ? syncDirection == SyncDirection.ServerToClient + : syncDirection == SyncDirection.ClientToServer && isOwned; /// The unique network Id of this object (unique at runtime). public uint netId => netIdentity.netId;