Search Unity

Animator Instant transition after trigger condition is true on non-loop animation

Discussion in 'Animation' started by Hellwaiker, Oct 12, 2018.

  1. Hellwaiker

    Hellwaiker

    Joined:
    Jan 8, 2016
    Posts:
    118
    Hey,
    So I have this case:
    Animation 1 (Non-Loop): moves cube on X axis by 3 in 5 seconds.
    Animation 1 (Non-Loop): rotates cube on Y axis by 190 degrees over 1 second. (and starts on X pos at 3)
    Bool variable called Test

    I have a transition between animation 1 and animation 2, it's transition condition is set to trigger if my bool variable is false.

    What I want to achieve, Stage 1 plays fully and then if bool is false animation immediately transitions to Stage 2.


    Case 1:
    If I set exit time to 0 and fixed duration to 0 and false, this does not work for me as animation Stage1 can be interrupted before it plays fully. But transitions are instant.
    Case 2:
    I set exit time to 1 fixed duration to 0 and false, now animation will not interrupt until it plays fully, BUT once it has already played and is at hold, if I trigger transition with bool variable. What happens is animator will wait full 5 seconds (length of stage 1 animation) and only then transition to Stage 2 animation.


    How do I solve this within inspector so It both waits for animation for finish, but once it has finished and trigger is true it transitions immediately?

    I know I can use 1 frame Stage 1 End pose between them, and I know I can use script to check Stage 1 progress with a script before trigger a bool. I'm hoping for a cleaner solution.

    Thanks

    BTW here is the sample scene (no other assets) with setup I mentions. Cube and two animations: https://we.tl/t-yYIy9YGA7d