- Home /
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?
Answer by Subzero619 · Nov 05, 2014 at 05:41 PM
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.
Answer by hrishihawk · Jan 22, 2018 at 06:53 AM
Uncheck "Has Exit Time" in the transition inspector. It will let you play the desired animation immediately.
Your answer
Follow this Question
Related Questions
2D Animation does not start 1 Answer
Animator Condition not working correctly! 0 Answers
Animation gets extra components without doing anything. 0 Answers