Simple First Person Attack Script

Quite new with Unity iOS, and I am creating a simple first person game.
I have a first person prefab that moves with joysticks, and an enemy that plays an attack animation when in close proximity.
I need a way to make the first person loose health when the enemies attack animation is played for at least half of the animation, when in certain proximity of the first person prefab.
The animation can still fully play, but if the first person prefab starts running away before the animation is done, I do not want health to be removed since this would be un-realistic…
Should be a simple script (I believe), but not to sure on how to approach it…
Any suggestions or scripting help would be greatly appreciated!

In the animation window, call a function (which is in a separate script) within the attack animation. The script can use raycast to find the one being attacked as well as the distance. If the attacker is close enough, then apply damage to the other character.

Great! Thank you very much for your help!
Hopefully I can write a script for this, quite new to Javascript :slight_smile:
Will post my answer here (if I get it working) for others to see