Good evening
I’m a complete beginner at Unity. I want to program in my game, if Player1 plays a stroke animation for example and hits the HitBox of the other while executing the animation, Player2 should play another animation for example a step back. How can this be programmed?
I would appreciate any advice or tip, no matter how small.
What i would do is run an OnCollisionEnter function. (Unity - Scripting API: Collider.OnCollisionEnter(Collision))
And in the OnCollisionEnter function, I would run an if() statement.
For example
void OnCollisionEnter(Collision other){
// Check to see if the object is touching the enemy
// Don't forget to make all of the objects containing the hitboxes of P2 have the tag "P2"
if(other.gameObject.CompareTag("P2")){
//play enemy's animation
}
}