From 976edea4512618546af68706870a9788ab6d6c68 Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Tue, 16 Dec 2025 18:41:50 -0600 Subject: [PATCH] fix Issue with AnimatorOverrideController not being handled which could cause improper processing of the animator's layers and parameters. Issue with clients sending state changes from the NetworkAnimatorStateChangeHandler due to added HasAuthority check. When using a server authoritative animation model, owner Clients should still be able to send trigger updates to the server. --- .../Runtime/Components/NetworkAnimator.cs | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/com.unity.netcode.gameobjects/Runtime/Components/NetworkAnimator.cs b/com.unity.netcode.gameobjects/Runtime/Components/NetworkAnimator.cs index db2edff3df..2cde6a1be6 100644 --- a/com.unity.netcode.gameobjects/Runtime/Components/NetworkAnimator.cs +++ b/com.unity.netcode.gameobjects/Runtime/Components/NetworkAnimator.cs @@ -78,7 +78,7 @@ private void FlushMessages() private bool HasAuthority() { var isServerAuthority = m_NetworkAnimator.IsServerAuthoritative(); - return (!isServerAuthority && m_NetworkAnimator.IsOwner) || (isServerAuthority && (m_NetworkAnimator.IsServer || m_NetworkAnimator.IsOwner)); + return (!isServerAuthority && m_NetworkAnimator.IsOwner) || (isServerAuthority && (m_NetworkAnimator.IsServer)); } /// @@ -95,7 +95,8 @@ public void NetworkUpdate(NetworkUpdateStage updateStage) var hasAuthority = HasAuthority(); // Only the authority or the server will send messages - if (hasAuthority || m_IsServer) + // The only exception is server authoritative and owners that are sending animation triggers. + if (hasAuthority || m_IsServer || (m_NetworkAnimator.IsServerAuthoritative() && m_NetworkAnimator.IsOwner)) { // Flush any pending messages FlushMessages(); @@ -408,7 +409,18 @@ private void BuildTransitionStateInfoList() } TransitionStateInfoList = new List(); - var animatorController = m_Animator.runtimeAnimatorController as AnimatorController; + var animControllerType = m_Animator.runtimeAnimatorController.GetType(); + var animatorController = (AnimatorController)null; + + if (animControllerType == typeof(AnimatorOverrideController)) + { + animatorController = ((AnimatorOverrideController)m_Animator.runtimeAnimatorController).runtimeAnimatorController as AnimatorController; + } + else if (animControllerType == typeof(AnimatorController)) + { + animatorController = m_Animator.runtimeAnimatorController as AnimatorController; + } + if (animatorController == null) { return; @@ -432,7 +444,22 @@ internal void ProcessParameterEntries() return; } - var parameters = Animator.parameters; + var animControllerType = m_Animator.runtimeAnimatorController.GetType(); + var animatorController = (AnimatorController)null; + + if (animControllerType == typeof(AnimatorOverrideController)) + { + animatorController = ((AnimatorOverrideController)m_Animator.runtimeAnimatorController).runtimeAnimatorController as AnimatorController; + } + else if (animControllerType == typeof(AnimatorController)) + { + animatorController = m_Animator.runtimeAnimatorController as AnimatorController; + } + if (animatorController == null) + { + return; + } + var parameters = animatorController.parameters; var parametersToRemove = new List(); ParameterToNameLookup.Clear();