FirstGearGames / FishNet

FishNet: Unity Networking Evolved.
Other
1.39k stars 149 forks source link

NetworkAnimator triggers sets twice #689

Closed f2069 closed 4 months ago

f2069 commented 5 months ago

General Unity version: 2021.3.18f1 Fish-Networking version: 4.3.4R Pro Discord: https://discord.com/channels/424284635074134018/1248141217498267740 Package: Animator.BugReport040624.unitypackage.zip

Description Triggers on NetworkAnimator sets twice on server in editor and developer build. In release build works fine. On 3.11.8R bug not reproduced.

Replication Steps to reproduce the behavior:

  1. Run ClientHost
  2. Set trigger T1
  3. See in Unity Editor that trigger stuccked.
  4. Set trigger T2
  5. After animation, trigger T1 playing again - error.

Expected behavior Triggers must be set in animator once in editor and in any builds.

Screenshots

2024-06-05 11 52 18
FirstGearGames commented 5 months ago

I'll make sure this gets looked at especially since you got us a repo package, but it will have to be marked as low priority. I don't believe this is a NetworkAnimator bug because the NetworkAnimator doesn't unset triggers(unless you tell it to), Unity typically does that automatically when a condition is met.

More likely it's something in your Animation Controller.

f2069 commented 5 months ago

Unfortunately the bug is in NetworkAnimator otherwise it would not work correctly in the build or previous version of FishNet. But now this occurs only in the editor and in the development build. I've attached the package with animator.

  1. When we set trigger networkAnimator.SetTrigger(triggerKey);
  2. it's calls NetworkAnimator.UpdateTrigger and _animator.SetTrigger(hash); https://github.com/FirstGearGames/FishNet/blob/40686750fe5028d6a61941dcbffd8d0ec1671c41/Assets/FishNet/Runtime/Generated/Component/NetworkAnimator/NetworkAnimator.cs#L1396-L1400
  3. after this is called NetworkAnimator.TargetAnimatorUpdated and it's set same trigger second time https://github.com/FirstGearGames/FishNet/blob/40686750fe5028d6a61941dcbffd8d0ec1671c41/Assets/FishNet/Runtime/Generated/Component/NetworkAnimator/NetworkAnimator.cs#L1433-L1442
  4. Corresponding messages in the debug console on screenshot.

In version 3.11.8 condition #if !DEVELOPMENT was been inverse and works fine. https://github.com/FirstGearGames/FishNet/blob/4882f1c228a5fd00bdc97e27b269b6dfe740f945/Assets/FishNet/Runtime/Generated/Component/NetworkAnimator/NetworkAnimator.cs#L1423-L1442

FirstGearGames commented 4 months ago

The development check should not even be needed in this case. It was put into place to save bandwidth for clientHost but realistically the savings would be incredibly insignificant and the checks add cpu costs.

I've removed the #if DEVELOPMENT/!DEVELOPMENT block entirely which should resolve the issue.

Resolved in 4.3.6