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:
- The Player is Close enough to the enemy to be hit.
- 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.