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? :)
Thanks in advance, T-low
asked Jul 02 '15 at 10:48 AM in Blueprint Scripting
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.
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
answered Jul 02 '15 at 07:04 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here