Search Unity

Interrupting an animation which has an Exit Time

Discussion in 'General Discussion' started by jnbbender, May 28, 2019.

  1. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    281
    I am trying to figure if there is a way to do this. I have a character who can do a round house kick. When the kick is done he goes into a "melee idle" type of stance which lasts about 2 seconds. When the animation "completes" I would like him to return to the regular standing Idle.

    However, if the character wants to throw another punch or kick, he has to wait until the 2 second clip is over. I would like to allow him to move/punch/kick when he is in the "melee idle" state. How can I make the "melee idle" be interrupted by a punch/kick/etc. and have it timeout?
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    1,441
    Not sure if this works, but have you tried using the Animator.Play() method to invoke the punch/kick animation?
     
  3. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    281
    Yeah, I could start the animation then disable the animation manually, I was just wondering if there was a way to configure it in the editor somehow.
     
  4. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    1,441
    Doesn't each transition have it's own "Has exit time" check box? Can't you set it so the transition from melee idle to punch (for example) does not have an exit time, while keeping the exit time for the melee idle to standing idle?
     
  5. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    281
    Oh man! Now I feel dumb. Didn't think about having two transitions out. Thanks