Blueprint Communication reference to Actor
I'm trying to communicated with Blueprints which are not in the level by default, nor spawned at the moment of interaction. I have searched for hours, but just can't figure this out.
In my particular case I have 10.000 bananas which inherit their variables from a parent (fruits) actor blueprint and are spawned dynamically at runtime. Those bananas may be picked up, and stored in my inventory. From my inventory I may select a specific banana and use it. On use I want
I think the proper function for this are event dispatchers, however my problem is to reference the specified banana. The only option I see is to use "get all actors of class" but getting 10.000 actors and checking if they just were used can't be right. There must be a way to reference the "dispatching banana" or any other more valuable method.
I really need some help with this.
asked Feb 25 '15 at 10:07 AM in Blueprint Scripting
I would make all pickupable actors either be children of some pickup actor class or implement a pickup interface. Then you can implement the "onUse" function you will have declared in your interface/parent. This approach is quite generic as you could then "use" any item you wanted.
If you can safely assume all inventory items are of type fruit then you can just cast the inventory item to a fruit and call use.
The dispatchers main use would be if you wanted to be notified every time the banana was used, but it seems you sort of want the opposite. I am assuming that you have some pointer to the banana at the time you want to use it
answered Feb 26 '15 at 02:36 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here