Skip to content

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

Merged

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Aug 2, 2024

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

  • Fixed: Issue where a state with dual triggers, inbound and outbound, could cause a false layer to layer state transition message to be sent to non-authority NetworkAnimator instances and cause a warning message to be logged.

Testing and Documentation

  • Includes manual test.
  • Includes integration test.
  • No documentation changes or additions were necessary.

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.
@NoelStephensUnity NoelStephensUnity changed the title fix: dual triggers generating false state transition fix: dual triggers generating false state transition [MTTB-48] Aug 5, 2024
@@ -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))))
Copy link
Collaborator

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;
    }

Copy link
Collaborator Author

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...
👍

Copy link
Collaborator Author

@NoelStephensUnity NoelStephensUnity Aug 7, 2024

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).

Adding test for the dual trigger scenario.
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review August 7, 2024 01:43
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner August 7, 2024 01:43
Adding additional comments about the update.
@NoelStephensUnity NoelStephensUnity enabled auto-merge (squash) August 7, 2024 01:57
@NoelStephensUnity NoelStephensUnity merged commit b2f5e84 into develop Aug 7, 2024
24 checks passed
@NoelStephensUnity NoelStephensUnity deleted the fix/dual-triggers-generating-false-state-transition branch August 7, 2024 02:38
NoelStephensUnity added a commit that referenced this pull request Aug 13, 2024
This is an up-port of the #2999 NetworkAnimator fix.
NoelStephensUnity added a commit that referenced this pull request Aug 13, 2024
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Network Animator error on Client: [DestinationState To Transition Info] Layer (0) does not exist!
2 participants