Blueprint Communication? How to get variable from different blueprint?

Hi,
I have a character with an raycast, also I have an X amount of objects from different kinds.
I know the method to communicate for example with an chest, by getting the variable chest and getting it’s components.
But I want to get a variable or start a function from any of all these objects (X) tree, chest, pen, gold, …and so on, when the 500 unit ray hits an object and the player presses F without declaring each object in the FPC BP.

Hope I used the right terms and described it well… understandable? :slight_smile:

Thanks in advance,
T-low

If you have lots of different blueprints and you want them to all share some sort of interaction then your going to need to either implement a BlueprintInterface in each of them then override one of the interface functions per blueprint or create a custom ActorComponent blueprint that you can check for and call functions on.

The interface will allow you to call the function on any blueprint that implements it but there is no default functionality. Each blueprint must override the interface function and handle it. You would do your line trace, get the returned HitActor then check if it has your interface with the DoesImplementInterface node. If it does then call the interface function. This allows for very specific effects on individual blueprints but a good bit of work and copy paste usually.

https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/index.html

The ActorComponent blueprint route allows you to predefined generic functionality and add that to any blueprint just like adding a light or mesh component. In this example your would line trace to your object, use the returned hit actor by doing a GetComponentsByClass on it and then check if that returns any valid components. If it does then you can call your functions on the returned component. This allows for generic effects on all blueprints with little work.

Aaaaanyway, hopefully this helps, let me know if you want more info

Thx for the help :slight_smile:

I now have a trigger box around all my Interceptable blueprints, which starts/ends a event in my FirstPersonCharacter BP.
These save/delete the displayName and the Name I gave them in an array.
Now I know which Items are in reach and if the ray hits one I can get the name and interact with the vieved BP.

Is this method ok (in wirting clean code)?

Seems fine to me