Animator: is it possible to interrupt a transition?

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?

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

You can. If you click on the transition arrow, there’s a section in Settings called “Interruption Source” that you can change to tell it what is allowed to interrupt that transition. It’s kind of complicated to use though. This blog goes into a lot of detail on how to use it:

3 Likes

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.

1 Like

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. :wink:

1 Like

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.

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.

Well, apparently the reference to that blog is already included in the help document. Look at the bottom of this screenshot.


I guess this was added recently, I’ve come through that page lots of times and I don’t remember seing it before.

1 Like

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!

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)

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.

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.

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.