Search Unity

Animator.CrossFade interrupts other active cross fade

Discussion in 'Animation' started by cjacobwade, Aug 11, 2019.

  1. cjacobwade


    Jun 8, 2013

    Running into an interesting issue when I use CrossFade to force my character into an animation state very soon after doing the same with another CrossFade.

    So at frame 10, lets say I call this:
    animator.CrossFade("Jump", 0.2f);

    Then if I call this within 0.2f of the first call, the animator pops to the called animation with no fade:
    animator.CrossFade("Dive", 0.2f);

    I've found a way around this by not using CrossFade and instead playing a bespoke animation state with a bespoke transition hooked up to the state I'm trying to fade towards, but obviously that's annoying.

    Is this the intended behaviour of Animator.CrossFade and why doesn't it make sense for a new CrossFade all to cancel the previous fade and start a blend from the pose at that moment?

  2. Kybernetik


    Jan 3, 2013
    I know of a few semi-related issues, but none that I would expect to cause that particular issue:
    • Calling Play("Jump") then Play("Dive") in the same frame would play the jump state and ignore the second call.
    • If you just played the dive animation and it is still fading out, then trying to CrossFade back into it will not work (but again it just gets ignored rather than popping into the animation like you describe).
    • For some reason they decided that the default CrossFade should use normalized time instead of seconds, so that isn't actually 0.2 seconds, it's 20% of the length of the animation. I'm not even sure whether it's referring to the current animation or the one you're trying to transition towards. CrossFadeInFixedTime uses seconds.
    If you're interested in a better animation system where you don't have to deal with Animator Controllers and stupid issues like this, you should check out Animancer (link in my signature).