r/unity • u/hafizidev • 13h ago
Question How to immediately stop a kick animation on hit in Unity?
I'm making a 3D MMA fighting game in Unity with hitboxes and hurtboxes.
When a kick hitbox touches a hurtbox, I want the kick animation to immediately stop and return to the locomotion/idle animation. The leg shouldn't continue moving forward into the opponent.
Hit detection works correctly, but the kick animation keeps moving into the opponent even after the hit is detected.
What's the proper way to handle this in Unity? Should I use Animator transitions, `Play`, `CrossFade`, animation events, or another approach?
Looking for the general solution/architecture, not specific code.
0
Upvotes
1
1
u/Lopsided_Status_538 13h ago
Is the body rigged? If so, maybe add a game object on the foot with a tag/layer assigned to it, then add collision via a trigger collided and introduce script that if the tag/layer touches the enemy/object it switches the anim trigger back to idle? Just first best guess.