Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Animator: is it possible to interrupt a transition?

Discussion in 'Scripting' started by EnriqueGato, Sep 24, 2017.

  1. EnriqueGato

    EnriqueGato

    Joined:
    Sep 3, 2016
    Posts:
    81
    My problem is, when I want to immediately fire a transition with animator.SetTrigger command, if the character is already playing another transition, it will wait until it finishes before playing the new one. This feels weird when you need a fast response on the animation (for example in attack transitions, you want them to start instantly, no matter what is going on).

    Is it possible to interrupt the transitions in progress by code?
     
    Last edited: Sep 26, 2017
  2. EnriqueGato

    EnriqueGato

    Joined:
    Sep 3, 2016
    Posts:
    81
    I'm not sure if I'm asking something too hard, but I'm unable to find any reference on this issue. Any help will be more than welcome.

    Thanks
     
  3. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Bunny83, apostelzhuk and LabOSM like this.
  4. EnriqueGato

    EnriqueGato

    Joined:
    Sep 3, 2016
    Posts:
    81
    Oh, wow. This is a big one. I've been trying to find this information literally for months, and honestly I was a bit hopeless to find an answer here.

    That post should be part of the main Unity help reference, or at least be linked or refered somewhere.

    Thanks a million. I'll try this ASAP.
     
    Last edited: Sep 26, 2017
    makeshiftwings likes this.
  5. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Yeah, Unity has a bad habit of putting really important information in their blog instead of in the actual documentation. There are tons of Unity features I'd have no clue even existed if it weren't for a random blog post. ;)
     
    hippocoder likes this.
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I agree, it's a poor habit. I like that they do actually make this information but I have had to search +blog to get some information (enlighten, etc) from the blog and it's only because I check often enough that I'm mindful of what to look for in there. I'm sure I've missed some too.

    @Buhlaine maybe some docs people can plunder the blog often or maybe the learn team can use some of these materials.

    I think really though, Unity is going best it can. If you think about it, it's a lot of documentation to cover and it keeps changing.
     
  7. EnriqueGato

    EnriqueGato

    Joined:
    Sep 3, 2016
    Posts:
    81
    I always say Unity is the most documented platform ever. It's really easy to find information about almost anything you want to find. Maybe that's why I miss this kind of documents to be easier to find.
     
  8. EnriqueGato

    EnriqueGato

    Joined:
    Sep 3, 2016
    Posts:
    81
    Well, apparently the reference to that blog is already included in the help document. Look at the bottom of this screenshot.
    IMG_3214.jpg
    I guess this was added recently, I've come through that page lots of times and I don't remember seing it before.
     
    Last edited: Sep 27, 2017
  9. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    402
    How can I do this via script?
    I have an attack animation that I want to be able to interrupt with itself, but this seems to be just IMPOSSIBLE.

    I have a mechanim like:

    Attack -> IdleBlendTree

    And then I run this after the attack is playing:

    Animator.Play(Asset.Clip.name,0, 0f)

    AND IT STAYS IN THE IDLE BLEND TREE. This is so frustrating.
    Just let me tell you exactly what to do, animation system!
     
    Last edited: Jan 8, 2023
  10. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    574
    You shouldn't Necro old posts like this. If you have a similar question it'd be easier to just make a new post.

    Change it to Animator.Play(Asset.Clip.name,-1, 0f)
     
  11. Xelnath

    Xelnath

    Joined:
    Jan 31, 2015
    Posts:
    402
    It doesn't work, that was one of the first things I tried. The transition to the walk state remains running. And sorry about the necro, this thread is what popped up on google when I searched for the topic.
     
  12. Rin-Dev

    Rin-Dev

    Joined:
    Jun 24, 2014
    Posts:
    574
    I misread what you posted. I thought you were trying to play the attack animation again.

    Unfortunately, you can't call animator.play on Blendtrees.
     
  13. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,364
    I think it's pretty easy to make a new state that immediately transitions back to the state with the blendtree, and jump to that new state if you need to interrupt.