Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Transition "Has Exit Time" and Conditions bug ?

Discussion in 'Animation' started by meg97, Mar 31, 2021.

  1. meg97


    Sep 29, 2020

    On the unity manual it is written:
    "If you have Has Exit Time selected for the transition and have one or more conditions, note that the Unity Editor considers whether the conditions are true after the Exit Time. This allows you to ensure that your transition occurs during a certain portion of the animation."

    But on my test, the transition condition is only checked once on the "Exit Time" frame and not after.
    Is it a normal behaviour ? (I'm on the 2020.3LTS) Can't we just have the animation time in the condition list ?

    What is the best way to make transition condition check after a certain duration of the animation ?
    Last edited: Mar 31, 2021
  2. morphex


    Dec 18, 2012
    I am interested in the same, how could you trigger specific conditions after lets say 30% of the animation has played.
    This could be solvable via scripts, but I am trying to figure out how to use the native tools before coding my own solution.
  3. Kybernetik


    Jan 3, 2013
    You'll have to code it yourself. Animator Controllers are not flexible enough to handle even common behaviour like that.
  4. morphex


    Dec 18, 2012
    Yeah, I reckon thats the case, I actually been eyeing your Animancer plugin, just because it seems to solve quite a bit of hassle, I just need a good ui built on top of it, similar to Mecanim. I guess thats an option.
    I am interested in making transitions between animations that mesh decently, - think combos in Devil May Cry game. That requires gameplay and good animation transition.

    How far off animancer is of that ? Specific transitions and blends?
  5. Kybernetik


    Jan 3, 2013
    Animancer's Transitions are a bit different from those in Animator Controllers. Instead of being a specifically defined pair of "A -> B", Animancer's Transitions are just the " -> B" part and it's entirely up to you when to tell it to play a transition.

    It also has End Events which would be useful for this situation because they are actually triggered every frame after the specified end time has passed, so if you want it to do something if 30% of the animation has passed and another condition is met, it could look like this:
    Code (CSharp):
    1. [SerializeField] private AnimancerComponent _Animancer;
    2. [SerializeField] private AnimationClip _Animation;
    4. void PlayAnimation()
    5. {
    6.     var state = _Animancer.Play(_Animation);
    7.     state.Events.OnEnd = OnAnimationEnd;
    8.     state.Events.NormalizedEndTime = 0.3f;
    10.     // Or set the time and callback at the same time:
    11.     state.Events.endEvent = new AnimancerEvent(0.3f, OnAnimationEnd);
    12. }
    14. void OnAnimationEnd()
    15. {
    16.     if (CheckYourOtherConditions())
    17.     {
    18.         _Animancer.Play(// the next animation.
    19.     }
    20. }
    Or if
    was a transition (probably a
    ), you would be able to set its end time in the Inspector so that you can easily tweak and preview it. You can also set the callback in the Inspector like other Animancer Events, but I generally prefer setting them in code because it keeps all your actual logic inside the scripts.