Sphere Trace For Object hitting too many times

I’m using a Sphere Trace For Object for hit detection, on the “hit actor” output I have my “take damage” logic that works fine, but since there are multiple Sphere spawned during the attack animation, each of them calls the damage logic, so in a single attack I hit too many times.
How can I tell to the game to make me hit a single enemy only once per attack?


I read that I can use arrays and “addunique” function but I really don’t know how, can’t even find a tutoria or recent thread anywhere.

Hello @BlueTitan99

I think that would involve having a anim notify in your animation’s at point where you would make contact with the enemy. You would use that notify to call a function inside your player, eg. PerformAttackTrace. You would need an array of “HitActorsThisAttack” and you would clear that array every time you perform a new attack.

So it might go something like this
PerformAttackTrace (from anim notify), check if hit is true, check if this actor is already in your array (get array → Contains → branch), if true do nothing, if false, apply damage and add unique to array.

There might be a better way of doing this, perhaps overlap event and collisions, but that’s up to you to decide.

You can convert your function into a custom event and use a Do Once node. Then you can reset after the end of the attack. You could also use a bool that you set to true after an attack connects and then set it to false after the end of the swing. Is your attack a projectile? Melee?

Macros are incredibly convenient btw.

Yes that’s the way, I only add that there’s need to clear the array of hitted actors at the start of each attack so you can hit the target again