Download

Overlap different actors and selecting one

Hi — I’m trying to develop a script to get all the actors from a certain class overlapping a collision component in the character, and select the closest one.
Just to be clear, all the actors that I want to be overlapped belong to the same “interactable” class, and possess the same blueprint interface. When an actor is overlapped, a boolean inside the actor must be changed so that the actor is focused; when the overlap ends, the focus does too. When more than one actor overlaps the capsule, the scripts must choose one and one actor only.
I’ve tried a couple of systems, but they do not work (see attachments).
Any idea?

Thanks

Im not sure how the array is ordered but you can always check the distance with “GetDistanceTo” node or calculating the Vector length with Vector A - Vector B -> VectorLength.
Same result but you for the GetDistanceTo you need 2 actors while the VectorLength only needs 2 vectors.

I would work with a function here because local variables come in handy.

I check my enemies distance from an array and made a video awhile back on it…

Let me know if you’ve questions…