Player lose damage when enemy is attacking (animation)

Ok, so I have an enemy character that does an attacking punch animation.

How would I go about calling a function to make the player lose health and include a punch sound effect when an enemy punches the player.

I would need it to execute the function only if all of these situations are met:

  1. The Player is Close enough to the enemy to be hit.
  2. The function would only execute when the punch part of the animation actually connected with the player.

I just had an idea of having an invisible capsule gameobject to be a child object to the enemy and have it just in front of the enemy. This object will be used as a trigger. (isTrigger on)

And when the enemy does its punch and the player is within that trigger object call the function from the enemy’s punch animation. (animation event call)

I’m going to try this.

Would this be a good solution?

Has anyone else done it a different way?
I would be interested to know your method.

Cast a ray towards the player, and see if it’s lenght is lower or equal to what you want(if you are not familiar with raycasting read the documentation).

For the animation part, I guess you can check the number of the current frame, but I never did anything like that, I might be wrong.