Search Unity

Animator Waits for "Next" Exit Time before leaving Non-Looping Animation Even After Completetion

Discussion in 'Animation' started by Callumnibus, Jun 28, 2019.

  1. Callumnibus

    Callumnibus

    Joined:
    Jul 23, 2015
    Posts:
    4
    I'm not sure if this is a bug or not but it's bugging me (lol). The title says most of the issue. I have an animation that is non looping. It's transition to the next state has exit time checked and set to 1.

    When the transition condition is met, the transition away from the non-looping animation is delayed by what I can only put down to the animator waiting for the exit time. This is obviously fine if the first animation hasn't yet finished (as in my case it needs to fully play), but if it has been finished for some period of time it should transition immediately right? The exit time condition should be satisfied if the animation is just sitting at the end?

    And a follow up question does anyone know how to get around this?

    Thanks
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    1,829
    It sounds like a bug, but due to the black-box nature of the Animator Controller system there might not be a simple way around it. You could waste time fiddling with the transition settings to see if some obscure combination happens to do what you want, but you might end up needing to use a silly hack like manually checking the animation time every frame instead of relying on the Exit Time to determine when the animation is done.

    Alternatively, you could check out my Animancer plugin (link in my signature). It lets you clearly define all your logic in scripts instead of putting some bits in an Animator Controller and other bits in scripts then running into stupid issues like this where your script says "it's time to play the next animation" and Unity says "sure buddy, gimmie a minute, I'm not ready yet". Animancer always does what it's told and things like Waiting for Animations to finish are actually really easy to do.
     
  3. therobby3

    therobby3

    Joined:
    Jan 30, 2019
    Posts:
    76
    Bumping this because I am also having this issue. I am thinking this is a bug, as it doesn't seem like something that should happen. To clarify, it seems like the animator has an internal timer running for the animation, even though it is non-looping, and it waits until for it's own imaginary "loop" to complete before analyzing the condition again.

    Here is a break down. Let's say you had an animation of a player punching, and you wanted to hold on the arm extended animation until the player releases the punch button, at which time they would retract their arm.

    1. Create animation of player punching, with the last frame of the animation being the player with their arm fully extended.
    2. Let's make the punch animation very long, to emphasize the bug. Let's say 10 seconds.
    3. Set the Animation Clip's "loop time" property to false so it does not loop and holds on the last frame.
    4. Create a transition in the animator state machine from the punching animation to say an idle animation.
    5. Set "has exit time" to true for the punching animation and create a condition for the transition so it only happens when "isPunchHeld" is false.
    6. Test it and hold the punch key. Let's say the animation was 10 seconds, and you released the punch button at the 11 second mark. The transition would NOT happen immediate, like it technically should. Instead, it will wait again until the 20 seconds mark (10 seconds times 2) to evaluate the condition again.

    Hope this makes sense. I'm going to file a bug report for this, as it doesn't seem intended.
     
unityunity