Right now I have a capsule component on enemy characters. I want to make it so that while the enemy capsule component overlaps with my player component, it will do damage over time. The best example I can give is the PainCausingVolume. I want to deal damage to the player every second that the two capsules are overlapping.
To try and achieve this, I used OnComponentBeginOverlap and branches to start a timer before the enemy can attack again. However when multiple enemies are overlapping, they just add to the timer instead of having their own BP_Enemy Timer. I’m not sure if timers would be the best way to achieve this effect, but I’m still pretty new to game development.
Basically what I want to happen is that if the player touches an enemy, they will be damaged, but they can’t be damaged by the same enemy until 1 second passes. So each enemy touching the player would in theory have their own independent cooldown before they could attack the player again.
Alright, I think I figured it out!
I added in a CanAttack boolean that will set to true when the enemy spawns in, then it’ll turn off when the enemy attacks and delay for 1 second to allow for the enemy to attack again. The AttackPlayer event will handle the timer instead of the BeginOverlap, I think this solved pretty much all of my problems, but might look a bit redundant with AttackPlayer and DamagePlayer
this way the edge of the AttackCapsule doesn’t apply again right after ending the overlap and starting again.