Firing Custom Events From Specific Actor Of Class

So this may be hard to explain but I’ll try.
So I have an attachment that can be attached to many different guns. I need it to set fire a custom event in the overlapping actor that sets a variable to true. But I need it to do so for only the one it overlaps and not all of that class.
AttachmentBP fires the event (on begin overlap) with any actor in the Firearm Class.
AttachmentBP now needs to fire the custom event of (Attachment In Range) in the BP of the Actor(gun) it is currently overlapping.

how can i make it find which one its over lapping, and then fire the event in that BP without affecting any other Actors in that Class?

I thought something like this would work but it doesn’t.

if your just looking to get a reference to the overlapping actor then just drag off of the other actor pin.

oh and using get all of class and get 0 is a horrible way to try to get a reference to something.

I understand i can just drag from the other actor node, but what i need is for it to check if the overlapping actor is any of the actors in the fire arm class. i need it to fire a code if its the hand gun, but if the overlapping actor isnt hand gun, it needs to go to the next check and see if its rifle, then fire that code if it is, if not keep going through the list until it finds which gun it is and fire the code for that specific actor

Yes, it could be hard to explain but I’ve undrestood the problem even if I’m afraid to tell you that the question is a bit vague.

What you are saying is that you have a set of “attachments” actors you can attach to the actor we are in. These actors have a method called Attachment in Range you want to invoke when they stepped into FrostSight component.

If I’ve understood well: you want to make the actors interact with each other. In this case the best solution I can find is to implement an interface. Since you didn’t use it I suppose I have to introduce you interfaces:

An interface is a “promise of implementation”. Into an interface you can declare methods (functions or events) you will have in all the actors that implement it. Obviously it follows that you can’t have methods with the same name of the interface’s methods. Also you can send an interface message everywhere and to any object.

So what you should do is:

  1. Create a new interface (right click on Content Browser/blueprints/blueprint interface)

  1. Into the new interface create a new function. Rename it and sets it inputs/outputs.

  1. At this point, you need to implement your interface in the desired actors (in this case only the attachments, your character don’t need it). Go under Class Settings and add an interface. Mine is called “New Interface”.

  2. Create a new event “Attachment in Range” in all the attachments and link it to the code you want to execute when the the overlap event trigger. [if the image is too small right click on it and open it in an other tab]

  1. Into your character (or the actor who have the detector) create a new function with two inputs: an actor reference and the same variale of your interface’s method. In the method check if the actor implements the interface and then send an interface message at the input actor.

  2. On the detector’s overlap event, after an obvious valid check, call the function created in point 5.

Let’s me know if it worked!