How do I notify a blueprint of another objects event firing?
I need my gamemode blueprint to know about a specific event occurring in another blueprint in the game to modify the score of the game.
I was going to use broadcast until I saw it checks every object in the game if it needs to know of the event. Seeing as only a maximum of four objects in the game can fire this event and only the gamemode needs to know about the event it seems like it would be very inefficient to use it.
What would be the best way to go about this efficiently?
asked May 31 '16 at 09:41 AM in Blueprint Scripting
If you only want the GameMode to wait for 1 other object to send a signal, you need Dispatchers. How to implement it? You create the dispatcher on the blueprint that is going to send the signal and Bind a custom event on the blueprint that wants you want to "hear" at that event (in your case, GameMode). This is useless if you got multiple sources that can send the signal, on which you will need to use Interfaces. The difference is that on Dispatcher, the sender doesnt needs to know where he is sending the signal but the reciever needs to bind himself to the sender. The Interfaces works on the opposite way. you implement the interface on the reciever (dispatcher is implemented on the sender), then the sender uses a reference to the reciever and connect to the Target of the node and executes the event. The good thing about Interfaces is that they are more flexible, as you can get a result from the call, where a dispatcher only fires an event, and gives nothing back. Now...that answer is for the exact question (since you ask for object to an unknown blueprint), and Interface (as far as i understand) can become a little heavy on the performance if implemented on too many objects (dont quote me here, im not 100% sure) but in your case you want just the GameMode to be notified for a change. why dont you just add a simple event on the GameMode and call it on the end of the logic on that blueprint? even if its multiplayer, you can add an event to that same blueprint to be RunOnServer and then that event send the signal to the GameMode (since clients cant access GM directly). and not only that but i think you should store the score of the game on GameState. again, im not sure if this is for single or multiplayer but storing variables in GameMode that should be accesed by everyone will become troublesome if you want to access to it.
answered May 31 '16 at 11:24 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here