Skip to content

Commit 1fabbec

Browse files
fix
This is an up-port of the #2999 NetworkAnimator fix.
1 parent d2bc5d4 commit 1fabbec

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

com.unity.netcode.gameobjects/Runtime/Components/NetworkAnimator.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,12 @@ private void CheckForStateChange(int layer)
851851
stateChangeDetected = true;
852852
//Debug.Log($"[Cross-Fade] To-Hash: {nt.fullPathHash} | TI-Duration: ({tt.duration}) | TI-Norm: ({tt.normalizedTime}) | From-Hash: ({m_AnimationHash[layer]}) | SI-FPHash: ({st.fullPathHash}) | SI-Norm: ({st.normalizedTime})");
853853
}
854-
else if (!tt.anyState && tt.fullPathHash != m_TransitionHash[layer])
854+
// If we are not transitioned into the "any state" and the animator transition isn't a full path hash (layer to layer) and our pre-built destination state to transition does not contain the
855+
// current layer (i.e. transitioning into a state from another layer) =or= we do contain the layer and the layer contains state to transition to is contained within our pre-built destination
856+
// state then we can handle this transition as a non-cross fade state transition between layers.
857+
// Otherwise, if we don't enter into this then this is a "trigger transition to some state that is now being transitioned back to the Idle state via trigger" or "Dual Triggers" IDLE<-->State.
858+
else if (!tt.anyState && tt.fullPathHash != m_TransitionHash[layer] && (!m_DestinationStateToTransitioninfo.ContainsKey(layer) ||
859+
(m_DestinationStateToTransitioninfo.ContainsKey(layer) && m_DestinationStateToTransitioninfo[layer].ContainsKey(nt.fullPathHash))))
855860
{
856861
// first time in this transition for this layer
857862
m_TransitionHash[layer] = tt.fullPathHash;
@@ -860,6 +865,10 @@ private void CheckForStateChange(int layer)
860865
animState.CrossFade = false;
861866
animState.Transition = true;
862867
animState.NormalizedTime = tt.normalizedTime;
868+
if (m_DestinationStateToTransitioninfo.ContainsKey(layer) && m_DestinationStateToTransitioninfo[layer].ContainsKey(nt.fullPathHash))
869+
{
870+
animState.DestinationStateHash = nt.fullPathHash;
871+
}
863872
stateChangeDetected = true;
864873
//Debug.Log($"[Transition] TI-Duration: ({tt.duration}) | TI-Norm: ({tt.normalizedTime}) | From-Hash: ({m_AnimationHash[layer]}) |SI-FPHash: ({st.fullPathHash}) | SI-Norm: ({st.normalizedTime})");
865874
}

0 commit comments

Comments
 (0)