Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug Very Strange Problem (animator.crossfade)

Discussion in 'Editor & General Support' started by TragicallyCanadian, Sep 22, 2023.

  1. TragicallyCanadian


    Mar 26, 2020
    Not technically an animation problem, but seemingly a problem with the cross fade functionality. Or perhaps I am just missing something.

    I have over two dozen attacks per weapon type in my project, so I am no stranger to setting up attack states in the animator and I've never had this problem before. It's very odd.

    The Problem
    When attempting a "Guard Attack" animation, the animation plays normally as it should. However if I spam the input, the animation still plays regularly but for a single frame the character model does the default no animation/avatar pose like this.



    It Gets Weirder
    1. If I place a "blank" animation state, and set it to transition into that state before going back to my default empty state. The bug does not occur.

    2. If I change "animator.Crossfade" to "animator.Play" the bug also does not occur.

    Things I've Attempted
    1. I've tried different animations, they all have the same result.
    2. I've made sure the code that fires the animation is only being called one time (To call it again you must wait for the action to finish, which happens when it returns to the "Empty" state you see above)
    3. I've checked for other animations being played at the same time, there are none.
  2. TragicallyCanadian


    Mar 26, 2020
    I have no idea why, but for future people with this problem. This fixed it.


    Setting the transition duration on the transition state from the attack to the empty fixes the problem. The weird part is, I have animations on this same layer where the "Transition Duration" is above 0. If somebody knows why this fixed the issue, I would love to hear it.
    Kurt-Dekker likes this.