- Home /
How to make 2 Animations or Models Interact With Each Other?
Hello, Please help me, how can i make 2 animations or models that can interact with each other?, example: when your character play animation punch enemy in the head enemy will play animation hold their head or when your character play animation stab enemy with a knife to the stomach enemy will play animation hold their stomach and fall down.
Answer by Rygaran · Mar 07, 2018 at 03:07 AM
You would probably want to have the player send a message to the enemy to both check that the punch hit and call some public function in the enemy for that. So when you punch you should use a collider, or a raycast, or whatever you prefer to detect the enemies that were hit and call some OnHit() function, where you can have extra parameters for the strenght of the hit that you can use to determine wich reaction animation to play. OnHit should then call the enemy animator and tell it to play said animation either with Animator.Play or Animator.Crossfade. You should also use this function to calculate the damage dealt, and decide if you want a hit animation or a death animation.