Line Trace Mulpiple Objects

Hello to everyone, I’m new to Unreal and I’m following the suggestion that all you give…thanks a lot. I have a problem relate to the screen. I created an animation for the attack and added a sword, I use a ‘line trace by channel’ to hit the enemy: the problem is that I want to hit the enemy only one time for animation/attack (damage 1 health), while the linee trace produce multiple attack within one animation (5-6 health depending the situation). How can I say that every animation (click button) has to damage only one time? thanks

I resolved the first problem with some boleans but I don’t think is totally correct. Are there better methods to this kind of situation? The new problem is that I can deal damage at one enemy per time, so I can’t attack different enemies even if they are in the range of my attack

Just have an array of actors, and when you hit an actor first check if the actor is in the array, and if not, add it to the array (AddUnique) and damage it

Every time you start the attack, remember to clear the array, and that should be it
You should then be able to hit multiple targets per attack, but only hit each target once per execution

You can put a recovery delay on the enemy that so that it won’t take any more damage after first hit.
It’s how nintendo games used to do it.

But that causes the issue of multple attacks may miss.

The better solution is to

  1. create a box collision that’s infront of the player.

  2. in the animation, create a custom anim notify that fires somewhere on the animation.

  3. in the animation blueprint, call the custom anim notify you created, cast it to the player BP and that calls the damage

  4. in the player BP, use get overlapping actors node for the box collision you added and apply damage

This should solve the problem and give you freedom to change animations without touching the code.
PM me if you need more help.