Actors of event called "On Component Begin Overlap (Box collision)"


I am making a multiplayer game and in the enemy I am using in blueprint the event called “On Component Begin Overlap (Box collision)” which has an output called “Other actor” which returns “Actor Object Reference”. I also have 3 players that are each a different blueprint called “BP_character1”, “BP_character2” and “BP_character3” Is there any way to get a “BP_character1 Object Reference”, “BP_character2 Object Reference” or “BP_character3 Object Reference” from the “Actor Object Reference” that returns “Other actor” from this event?

Thank you very much.

Cast Other Actor to any of your other blueprints, if the cast succeeds that means that Other Actor is of that class

1 Like

Yes…you must cast it

cast the first class…if fails cast to second class if fails cast to 3rd class…

Hi there,
Are these three bps childs of a common parent class?

I would strongly recommend using interfaces to avoid casting. From other actor, call “does implement interface?” + branch. If true, connect other actor to a interface message, so you can send (interface function inputs) or retrieve (interface function outputs) variables to/ from those actors, and your code becomes class-independent.

An interface message node does the implement check behind the scenes, no need to do it manually

1 Like

Thank you all very much for your answers.

Yes, the three BPs have a common parent class, but each child BP has its own variables which are the ones I want to set depending on which BP has collided with the enemy.

I have been looking at the interface, but it is not very clear to me how it should be.

In the case of the “On Component Begin Overlap (Box collision)” event, what is the type of input variable that the interface function should have? Actor? and if so, would it be an actor class reference or another type?

Where “Actor Out” would be the BP of the character with which the enemy has collided.

Would it be something like that?

If not, could you give me an example of exactly how it should be done with blueprint?

Hi there,
You are moving forward. Unfortunately, I am out of town without my computer. I’d appreciate if someone could print an example to help you out. Let me try to explain:

There are two types of implementation.

  1. Using inputs to execute the rest of your code inside the Player BP (“by sending a message to the player”). Then, the “actor in” can be type “enemy BP” reference (blue pin), and you “get a reference to self”. In your setup, “self” is the actor sending the message to the player ( in this case, your enemy). Here you can add any variable you want to send to the player. Inside your player parent class, go to class settings, and look for interfaces. Click on plus and add the new interface you’ve created. Then, anywhere in the event graph, right click and search for “event custom actor event”, to bring in a red custom event with a blue icon representing interfaces. From there, you’ll see the “actor in” pin representing the enemy overlapped. Now, you can retrieve any variables you see fit from the enemy to continue your logic inside player BP.

  2. If you add output pins, you want to execute the rest of the code inside the Enemy BP (“by retrieving information from the player”). Then, the implementation is different. Again inside your player parent class, go to the left panel (where you’ll find all variables, functions, macros and interfaces), look for the interface section, and you will see the “custom actor event”, double click to edit it and there you can link desired variables specifics from the player, not necessarily only “actor out”. This setup is used inside the enemy BP to retrieve desired information from the player.

I hope that makes sense.