Cancel current animation automatically and start it again when same animation triggered

I have like this state:

When something hit with projectile I’m triggering Hit animation like this:

animator.SetTrigger("Hit");

But if something hit two times in a row then it waits for first hit animation to end and plays second hit animation after that. But I want current animation to cancel and start hit animation immediately. Otherwise second hit animation starts delayed.

Tried:

animator.animation.Stop();
animator.SetTrigger("Hit");

and it not worked.

So what I want is canceling any animation running currently and triggering hit animation so it won’t be delayed.

Many animations would require starting instantly without waiting old animation to end, I don’t understand how animator not supports this by default or is it supports and I can’t find it?

This is very easy, on the transition from idle to hit, click that arrow and on the side there should be a checkbox with Atomic, this should be either ticked or unticked (can’t remember).

Then you can simply use SetTrigger.

Uncheck “Has Exit Time” in the transition inspector. It will let you play the desired animation immediately.