-
Notifications
You must be signed in to change notification settings - Fork 447
fix: dual triggers generating false state transition [MTTB-48] #2999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: dual triggers generating false state transition [MTTB-48] #2999
Conversation
This fixes the issue where a trigger that transitions to a state with a trigger that transitions back to the original state could cause NetworkAnimator to generate a false layer to layer state transition which would not only generate an additional message after the original trigger message, but would cause the non-authority instances to log a warning message.
This includes additional assets needed to test this fix manually as well as some of the assets included will be used in an integration test.
@@ -832,7 +832,8 @@ private void CheckForStateChange(int layer) | |||
stateChangeDetected = true; | |||
//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})"); | |||
} | |||
else if (!tt.anyState && tt.fullPathHash != m_TransitionHash[layer]) | |||
else if (!tt.anyState && tt.fullPathHash != m_TransitionHash[layer] && (!m_DestinationStateToTransitioninfo.ContainsKey(layer) || | |||
(m_DestinationStateToTransitioninfo.ContainsKey(layer) && m_DestinationStateToTransitioninfo[layer].ContainsKey(nt.fullPathHash)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: I wonder if we can split the condition into simpler checks, which makes it easier to understand.
else if (!tt.anyState && tt.fullPathHash != m_TransitionHash[layer])
{
bool containsLayer = m_DestinationStateToTransitioninfo.ContainsKey(layer);
bool containsFullPathHash = containsLayer && m_DestinationStateToTransitioninfo[layer].ContainsKey(nt.fullPathHash);
if (!containsLayer || containsFullPathHash)
{
// first time in this transition for this layer
m_TransitionHash[layer] = tt.fullPathHash;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah... it would really be nice to have access to some of the Animator stuff that is available in the editor at runtime...but it gets boiled down to these condensed states.
Although, I think you made me think more about this and that it probably needs some comments...
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some additional comments about that crazy logic... but basically it is avoiding from sending a animation transition that was a trigger to state or trigger from state back to Idle(state) transition which is already sent when one of the two triggers was already set (and sent via RPC).
* fix This is an up-port of the #2999 NetworkAnimator fix. * test The ci runtime and editor manual tests for this fix. * update Adding changelog entry.
This fixes the issue where a trigger that transitions to a state with a trigger that transitions back to the original state could cause NetworkAnimator to generate a false layer to layer state transition which would not only generate an additional message after the original trigger message, but would cause the non-authority instances to log a warning message.
MTTB-48
fix: #2828
Changelog
NetworkAnimator
instances and cause a warning message to be logged.Testing and Documentation