So I have enemy pawns running around the level, each of whom has my override version of TakeDamage() to correctly manage reducing their health, and I’m trying to work out how the labor needs to be divided in the combat module. There are two basic sequences of events that need to occur when the attack key is pressed:
Player checks internal movement state (standing vs. flinching vs. ragdolled) to determine if they can attack. If they can, player model starts playing the desired attack animation.
For every frame of the attack animation where the attack does damage, every enemy who IS within range (as determined by a trigger sphere in front of the player) and has NOT taken damage from this attack yet runs TakeDamage().
Task 1 seems like a perfect task to handle purely within the animation state machine, as it’s literally playing animation rock-scissors-paper, but I’m really struggling with how to make task 2 work alongside the state machine- if each attack only hit on one frame, I could simply run my ApplyDamage function on that frame, but I’m really lost on how to test for enemy vulnerability without applying damage every frame they’re within range.
Is there an obvious, clean way to ensure that the animation logic and the attack logic sync up, or am I taking the entirely wrong approach here?