How to identify which actor is being attacked?

Is “MyEnemy” being set correctly? It seems like you want to call OnAttackMissed on the “OtherActor” pin from the OnComponentBeginOverlap event. That should be the enemy actor your sword box is colliding with.

Hi

so ive set up an actor bp for my enemy ai (and spawned 3 actors from the class) and have created an On begin overlap node in another bp for playercharacter to trigger enemy ai to animate when attacked. But when i attack an enemy ai, no matter whether i attack actor 1, 2, or 3, actor 1 animates rather than the one im attacking.

How do i set up my bp so that the actor im attacking will animate, leaving the other actors unaffected?

yeah i set MyEnemy with a Get all Actors of Class and hooked up an IsValid which says it works, also set up a print string in the OnAttackedMissed which prints on overlap.

I tried setting up OnAttackMissed with the OtherActor but isnt valid.

You’ll need to cast OtherActor to the enemy class for it to be valid.

Like this? the cast fails

Does the cast fail on FAILED1 or FAILED2?

it fails on 1

Then it sounds like its not an enemy that is triggering the overlap. Is there another actor that could be triggering the event?

If there are multiple types of actors that can trigger this overlap, then add the Enemy cast and when it fails don’t call OnAttackedMiss.

Generally you want to use the event information instead of using GetAllActorsOfClass. If you do the latter you have no way of determining which enemy you’re hitting.

there arnt any other actors that can trigger the event

Can you add some logs to find out what actor is being overlapped?

Just looking at this I can see your wiring is all messed up to use an overlap event trigger. You should never use an overlap trigger output pin (in this case actor overlapped) to be the input for a separate execution chain. I can’t see the whole chain there but I can already see issues in the logic. What happens when the green chain executes and nothing overlapped the sword collision? It will pull a null value for the actor pin and feed that into the cast causing it to fail. Additionally, you ask the sword collision to do something “on overlap” but you don’t tell it what it should be checking for in the overlap category before executing because you took that output pin and placed it into a separate chain of events. How will it know if it is finding what you wanted it to find during begin overlap if you dont use the output pin for the overlapped actor in the same execution chain to filter out appropriate overlaps from inadvertent ones? Move the cast to enemy node in line with the overlap execution node. Didn’t understand the whole set-up after that so not sure what else needs to be done to get it working but I would def. switch the wiring around and then let me know what else is going on and I will see if I can help you figure this out.

ok, so moving my cast to after the overlap event worked. cheers for pointing out my mistake :slight_smile:

Haha no problem, glad I could help!