Using Event Dispatchers on the same class

Hi, I’m trying to implement a system where civilians flee when a crime is commited and when all is clear they go back to being idle. The problem is that I thought I had a solution in mind using event dispatchers but they confuse me somewhat.

Here’s a few screenshots. Note that all of this is on the same class (blueprint)

Here’s the binding for the event, when the event is called the NPCs go back to idle:

Here’s what’s sort of confusing me. When I call the event it requires a reference to the object that holds the dispatch. Since the class itself holds the dispatch my assumption is that the call will propagate to each instance of the class. This doesn’t seem to be the case, the call event of the first image triggers on the instance that is calling it and no other instance. If I get all actors of the class and call the event on each instance it works just fine (second image).

So my question is: what are event dispatchers used for? If I need the reference to every instance (not class) that holds the dispatch, why would I use a dispatcher and not just use interface calls or a function call directly on the reference?

Thank you!

Each NPC needs to bind to one central actor. They can bind to two calls, ‘crime committed’ and ‘end flee’.

When the time comes, the central actor either calls ‘crime committed’ or ‘end flee’ and all the NPCs automatically get the message. No loops :slight_smile:

Thank you for the reply ClockworkOcean! I managed to get it to work. I created a dispatch on the game instance for now just to test it.

So just for my own understanding, event dispatchers are attached to an object, other actors bind themselves to the dispatcher on said object and when I want to propagate the event I call the dispatch on said object.

NEW_ED03

Am I understanding this correctly, conceptually?

Thanks again

1 Like

Yes, it sounds like you have it :slight_smile:

It’s just a broadcast.

1 Like