Download

Call a function from a blueprint to another

My problem is the following: when player interact with capsule (he is a trigger collion inside a blueprint) i want to call a function in CastleBP (another blueprint) that modifies the text above the static mesh. This function is called “set string”.
On the internet I found the only solution that shown in the graph below where I connect to the “OncomponentBeginOverlap” a “get all actors of class” and “CastleBP” as “Actor class” of this node.
So, when player enter in capsule, the function is called correctly. But I don’t think it’s the best solution.
Does anyone know if there’s another way?
I tried with a “cast to castleBP” but I never managed to make it work.
(Sorry for my english :-))

BP communication: your method, event dispatchers, interfaces.

Put a collision box on the castle. In the collision box “On Component Begin Overlap” put the following:

Two simple steps:

  1. In the blueprint of whatever class contains the capsule, create a variable of type CastleBP. Let’s call it “Castle”. In the capsule class event graph, near your OnComponentBeginOverlap node, get a reference to the Castle variable and use it to call whatever function you want to call that you have already defined in the CastleBP blueprint. Connect the OnComponentBeginOverlap node to the execution pin of the desired CastleBP function.
  2. Next, in your map, go to the World Outliner and find the capsule instance and click on it. In the details pane, you can set the Castle variable to the instance of the CastleBP that exists in your World outliner.

That should work.