NetworkAnimator causes StateMachineBehaviours to get called twice.

As title says. I have the following StateMachineBehaviour that informs my script of when an animation is done:

 override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (NetworkManager.Singleton.IsServer)
        {
            animator.gameObject.GetComponentInChildren<Whatever>().AttackFinished();
        }
    }

When the NetworkAnimation is enabled, this fires twice.
When the NetworkAnimation is disabled, it works as intended (only once).

Hi, I’ve been trying to reproduce your issue without success. I created an animation controller and some animations. I attached a StateMachineBehaviour to one of the animations with code in OnStateExit & OnStateEnter. Both behave for me exactly as expected. Each is fired once per machine per transition. The NetworkAnimator itself doesn’t invoke these functions; they are triggered by the animation. I even tried to force an animation to play twice, but the controller guards against that.

Can I assume from your code that you are seeing the firing happening twice on the server?

We haven’t done a lot to NetworkAnimator, but just in case can you re-test off of the ‘develop’ branch of the repo?

And/or, can you help me with a reproducer that I could run?

Hi Sorry,

Life got busy, so my project was put on pause for a bit. I apologize for not responding. I am still getting this behavior in pre6. I would love to help you reproduce this. If you would like, you can DM me with a meeting or discord invite and I can screenshare to demo this issue with you. Visually, it appears as if it is causing the OnStateExit to also be called on OnStateEnter

I have the same issue with netcode 1.8.0, client authority mode, network animator.
The host mode,the host works fine,
this problem occurs on both host and server mode, and only the client side,

when client side plays the shot animation, the state behavior will execute twice on server

Input.GetMouseButtonDown (once) → Animator.SetBool (once) → (Twice) StateBehavior::OnStateEntered

the animator.setBool is executed when networkvariable changed

for example.
I started an server(not host) and a client.
then attack,
then client: once → once → once
the server: once-> once → twice
Input.getMBD ->Animator.SetBool ->StateBehavior::OnStateEntered

I’m having the same issue with Mirror.

Animations on the host are going into the StateMachineBehaviour’s OnStateEnter function twice.

First, I run animator.Play(“animation name”). Then, the animator state’s OnStateEnter function runs as expected. Then, the second execution happens approximately 0.2s after, seemingly for no reason.

This is pretty annoying, as it causes some particularly fast animations to start for a frame or two, and then it goes back to the beginning of the animation and runs normally from there.

This issue happens only on the host, and I’m sure it’s related to the NetworkAnimator specifically because if I take it out from the object, the issue stops happening.

Does anyone know why this happens?