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. Dismiss Notice

How do you allow animations to interrupt each other?

Discussion in 'Animation' started by strich, Mar 24, 2015.

  1. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    346
    I'm trying to create a simple set of animations in a single Mecanim controller. I have setup transition paths from Any State to each of the animations. They all fire off and transition between each other fine. However they only transition when they've reached the end of their own animation clip, whereas I require a quick transition between each of the animations at any point in their animation clip timeframe.

    How do I do this?
     
    gibsonluke85 and krlozadan like this.
  2. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    If you are using 5.0 simply uncheck Has Exit Time on your transition, this will allow the transition to be trigger at any time while playing your state.
     
    AnniDin00, Allyoo, HoToFF and 16 others like this.
  3. SamTheT

    SamTheT

    Joined:
    Feb 21, 2015
    Posts:
    4
    I found an answer that kind of works.
    Make an Idle animation (and all the other animations that you need)
    Put them into the animator
    Connect "any state" to, for example, jumping and then connect jumping to Idle animation
    Then connect Walking animation to Idle and back.
    Now, you should be able to walk and jump any time you want. Walking animation will be terminated.

    Another theoritical solution is to connect "any state" to all the animations, except Idle, and then connecting all those animations to Idle. idk if it works

    p.s: if you didn't understand anything from what I said, just ask for a screenshot
     
    Monogrid likes this.
  4. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    346
    Thanks for the feedback. Yeah I eventually worked out the exact same solution through bruteforce attempts. :)
     
    Creepernuke likes this.
  5. narcis355

    narcis355

    Joined:
    May 30, 2016
    Posts:
    1
    You my friend are a life savior... i think i searched for this in tutorials for a clue for almost 1 h, thank you friend
     
    Nick_Laza and RobbyT15 like this.
  6. GameEverything

    GameEverything

    Joined:
    Feb 22, 2016
    Posts:
    10
    Sorry to bring up a dead thread, but this helped me, too. I bought a series of animations from the Asset Store and they all had exit time checked which was a major headache because waiting for an animation to end would involve a whole bunch of timing and seemingly redundant code. I was like, 'Nah, this can't be how it's done.'

    Thanks.
     
    Nick_Laza and RobbyT15 like this.
  7. RobbyT15

    RobbyT15

    Joined:
    Jan 8, 2015
    Posts:
    3
    Thank God for this comment. Had I not found it, I'd probably be trying to figure this out five years from now. Makes sense since Has Exit Time is the first condition checked.
     
  8. RickshawDerpyDerp

    RickshawDerpyDerp

    Joined:
    Nov 6, 2018
    Posts:
    23
    Turning off "Has exit time" does not allow the next animation to interrupt the animation that is currently playing.
     
  9. HonoraryBob

    HonoraryBob

    Joined:
    May 26, 2011
    Posts:
    1,212
    It doesn't work for me either, even though I'm using 5.0 and I've set AnyState to link to another clip when a parameter has a certain value. Isn't there any way to interrupt an animation clip?
     
  10. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    275
    I've never had issues with removing Exit Time to ensure state changes happen immediately. Technically this is not an "interruption" but simply allowing for immediate state changes. My best guess is that there something else blocking the transition from happening, like a trigger that has already been consumed.

    I prefer to work with floats and bools for this and a few other reasons (animation blending mainly). I also find it a little easier to visually debug in the Animator.
     
    the_0dium likes this.
  11. Kechy

    Kechy

    Joined:
    May 21, 2020
    Posts:
    2
    After some time I found a solution that might work for you as well, call the animation from code using Play("name"), then in Animator, make a transition from your animation state to Idle state, in transition settings, Has exit time should be on, make exit time 0.1, and transition duration 0.9, with the rest of the options being default ones without any additional conditions. Hope it helps you as well!
     
    Kububbis likes this.
  12. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,486
    animator.Play and animator.CrossFade can go directly to any state regardless of what transitions you have made.
     
    the_0dium likes this.
  13. the_0dium

    the_0dium

    Joined:
    Nov 29, 2018
    Posts:
    15
    If you uncheck "has exit time" and transitions don't fire immediately, you guys should really check your code. As suggested before, you are probably using triggers in a wrong way or it might be another mistake. In any case your problem is in the code.