Global EventDispatchers in GameInstance

Hi everybody,

I currently came across the fact I could potentially improve my Blueprint communications by using Event Dispatchers.

Some context :

However, my case is a bit special as I don’t have 1 sender and multiple receivers, but multiple senders and multiple receivers. Each and every sender has its own Event Dispatchers but they all have the “same ones” (hope what I say is understandable). That means the receivers need to somehow receive the references of all the senders and Bind the “same” Event for each of these senders multiple times.

You can see that it is a completely impractical way of working. I came across a first solution which uses a separate Blueprint Class to store all the EventDispatchers (would be like an “Event Dispatcher Library” of some sort). That means all the senders Call the same Events and the receivers only need to Bind an Event once. This is already a huge improvement, but now the receivers and the senders need to receive a reference to this “Event Dispatcher Library” instance.

However, some of my senders are User Widgets. It means that unlike Actors in the scene, their instances don’t exist until the execution. It then means that I cannot give them a reference to the “Event Dispatcher Library” instance from the Editor, but has to be done through Blueprints. I could certainly use the “Get Actor of Class” at Event Construct to retrieve the reference of the instance. But this node is marked as “slow” and I certainly would prefer to avoid using it.

My question :

After a few researches, I came across the existence of “GameInstance”. From what I understood, this is mostly used to save certain informations (like the character health) so they don’t get lost when changing Levels. But the GameInstance is also global, so accessible everywhere. And I can use it to make “Global” EventDispatchers that all my senders and receivers can access very easily. I tried and it works like a charm.

But is it a good idea ? Would I be making a mistake because there are things I don’t quite take in consideration or can I use the GameInstance that way ? Would love to hear what you guys think.

Thanks a lot in advance !

It would work OK if there’s no other way of moving data across. The method you mention is described here:

In this very case as a way to push data into the Level Blueprint as it’s notoriously annoying to do so. But yes, you could treat the GI as a dispatcher manager. It would receive calls and propagate data to whoever else needs it.

This way you get a less tight actor coupling - those actors really do not need to know about each other’s existence. They just talk / listen to the Game Instance… from anywhere.

On the other hand, I’ve yet to run into a non-Level Blueprint scenario that would render such undertaking unavoidable. But depending on the mechanics and how / when actors come into play, it may be necessary / more logical to do so, ofc.

This will become a wiring nightmare at some point so do note that this exists:

…and can be used inside a function. Besides that, it’s somewhat uncommon knowledge but Event Dispatchers can also bind directly to functions.

Another possibility is something like:

Global dispatchers are do-able.

Very interesting informations ! I’ll make sure to use the Create Event when needed. Thanks a lot !

Hi, can you please give your expertise. I searched “Global Event Handler” and found your post.

This asset is on sale, Im interested:

  1. What technology does “Global Event Handler” use? (E.g. Dispatchers?)

  2. How does “Global Event Handler” compare to the one you linked, “EventDispatcher”

  3. Are these still the best ways to do this goal in UE4.27?

Goal: I want to replace Cast To, and I want Actor A to listen for Event that gets triggered in/by Actor B. I believe that “Global Event Handler” does this easier [whatever default UE node there is]. But my concern is it’s a 2020 asset. Thus is this still the best way in UE4.27?

Thank you.

Both plugins look good. The fact they’ve been around for a while is a good thing actually. The last thing you want is to start using a plugin in your project, and then the writer bails.

To answer

It’s a plugin. The whole point is you make your own tech and are not limited to blueprint concepts.

Both are good it seems

Be sure you need a global dispatch mechanism. I say this because in your text, you say

This could be done with blueprint interfaces or event dispatchers.

1 Like

I meant what is the label of the tech, so I know what to refer to it as, what to search/compare.
This was a Dispatcher type tech, correct? Whereas “Triplanar” is a Material tech.

I might have messed up there. I didn’t know what “Global” meant. It seems to call all of “Car BP” actors placed in a map, not individuals? I bought it already. So I guess I can use it to call all AI for a gather & mob-attack Event. Or if you can direct me to examples of what to use a Global Event call for. Ty.

Ty. I use BPI now :slight_smile: . Still learning about Event Dispatchers (which I thought this Global thing was, I thought it could to both Global and Local).

The ‘tech’ is called ‘global event handler’. There is no official name, but that will get you what you want on the marketplace.

If you want to talk to all car BPs, then you can use ‘get all actors of class’ or dispatchers.

The whole point of these ‘global event managers’, is that you can register for events without knowing what is going to trigger those events. In the standard UE system, you have to know what kind of object you are registering with, which is weak from a modularity point of view.

BP interfaces are great for modularity. That’s how dispatchers should have been done, but they weren’t for some reason.

Anyway, so great modularity, but then you get the downside of it’s global nature, which is just like global variables. BASIC had global variables, and we all know about the problems they bring.

It’s really a balancing act :slight_smile:

1 Like