My characters have multiple collision capsules making up their hitbox, I’m using On Overlap Begin for collision. So every time the weapon swing overlaps a component it runs this function. If i set a boolean in the overlap function and then reset it after the swing completes I can only damage one actor per swing.
How can I damage each actor only once (if the swing overlaps multiple different actors)?
If the answer is using the overlap function to populate a TArray and then apply the damage in another function I’m not sure how that looks.
Yeah applying the damage in the End attack function could work, but for slower swings with longer active collision it would be awkward and delayed if the collision happens at the beginning.
This is working currently, if the enemy takes damage it sets the boolean, gets reset by timer afterwards.
I only have one method of dealing damage atm but would this idea work with other damage Instigators and Causers in the future. So certain attacks/damage prevent the character taking successive hits of damage and others don’t?
else if (DamageCauser = FireAoe)
{
Health -= Damage;
}
else if (DamageCauser = PlayerWeapon)
{
Health -= Damage;
IsHit = true;
}
Setting up collision channels for enemy and player attacks can definitely help organize things, but for multiple overlaps, in the class BP, when selecting the sword mesh component search collision, it’s in the tick boxes below the main channel responses
not necessarily, you must have something that begins the attack, for instance to start the montage, at that point you can create/clear the array, then on your OverlapBegin you can get access to that array.
then you can still apply damage exactly at the time of overlap.
there are always multiple ways to achieve a goal though