my willing is that to make NPC keep playing hit when the hit triggered by the player, after the dying event triggered, it should abort to play death anim immediately.
the funny thing now is that the hit trigger animation looks like queued but not canceled when the dying is triggered, after the NPC plays into dying animation, in the hit to dying half transition, it goes back to the hit animation, then goes to locomotion as idle, which is totally not expected.
I have set both transitions to Current and Ordered interruption , and make the anystate to death
I attached a statemachine behaviour script to debug out the state name OnStateEnter and OnStateExit
and wrote a debug script press every 5 times to trigger a die event ,
as you can see, after the dying event triggered, it should trigger and play the dying animation only, but the previously None finished hit animation still comes back and interrupt the dying animation.
It sounds like you’ve found the solution: reset your trggers and stop setting them once you know the character is dead. If you use triggers you will pretty much always want to reset all the others whenever you set one of them. Otherwise they will remain set until they get used so if you press jump while attacking repeatedly, it will either finish all your attacks before jumping or jump and then attack again when you land. Either of those would feel unresponsive for the player because you could be responding to inputs they made several seconds ago.
You might be interested in trying out Animancer (link in my signature) which lets you play whatever animations you want on demand instead of fiddling around with Animator Controllers, triggers, etc.
hi, Kybernetik
thanks for the reply, I will look into your asset definitely. for this reset trigger thing, Can I always reset it before trigger a new one event on the same trigger animation? like below:
//once press fire
aniamtor.ResetTrigger("hit");
aniamtor.Trigger("hit");
You can, but that’s pointless. A trigger is just a bool that will set itself to false when a transition uses it, so all you’re doing there is setting it to false then immediately back to true which won’t achieve anything different from just calling animator.SetTrigger.
What I meant is that when you SetTrigger(“hit”), you will want to ResetTrigger all of your other triggers such as attack, jump, etc. (obviously I don’t actually know what’s in your game). And when you SetTrigger(“dying”) you will want to ResetTrigger(“hit”) and all those others as well.
Necropost from a long time ago but google still brought me here lol.
One thing that helped me with this problem was un-checking the “Can transition to self” box in animation transition inspector.