Event Dispacther from NON player BP and Level Blueprint

Ok I have a BluePrint class which fires a dispatcher, properly.
Level Blueprint has to bind that dispatcher, of course using Player Character doesn’t work, so I’m casting to the proper BP but which object should I link to if that BP only has a staticMesh?

Ok I have a BluePrint class which fires a dispatcher, properly.

  • Is this just an actor or a pawn / character / something else?
  • How does the instance of this blueprint end up in the game?
  • Placed in the level manually?
  • Spawned dynamically?
  • How many are there going to be? Just one, or?

which object should I link

The instance of the actor that’s in the level, or that has been spawned from class, or instantiated by one of the framework classes.

Imagine you have 5 of those actors with a static mesh. How is the engine supposed to know which one of them you mean.

It is just an actor, no pawn or player.
It is not placed manually, it is spawned dynamically.
I need t spawn one or more depends on a set of variables

Thanks for the clarification.

So a dynamically spawned actor whose dispatcher needs to be caught by the Level Blueprint. Somewhat tricky by definition.

And one last question:

Which blueprint dynamically spawns them? Where is that spawning blueprint (framework class, level blueprint actor, also spawned dynamically by something else)? How does it end up in the game?

Apologies for the grilling but it’s sometimes convoluted how certain scenarios are set up. And communicating with the LB is a little nightmare at times.

1 Like

thank you and yes it is a nightmare!
Basically I have this Actor blueprint “A " that once hit” should spawn another Actor Blueprint “B” . The main problem is that actor BP B has to have an owner, that allows me to properly load/unload a levelmap with all his actors.

Both actors are not in manually placed in any maps because they are spawned by an algorhythm

Lets keep digging. Where is the algorithm?

After battling many dispatchers and Cthulhu like reference chains.
I decided that enough is enough.

And anywhere i can do it (like 99% of my dispatchers) i create pairs of dispatcher and event calling it in GameMode blueprint.

Game mode is easily referenced from any blueprint and actor, survives level load.

So for eg. if i want to trigger event dispatcher from player character:

  • in game mode create event: “event player farts”
  • in game mode create dispatcher: “dispatcher player farts”
  • now from player character get gamemode reference, and call event
  • every actor that needs to know about it, can get gamemode reference and assign to that dispatcher.

Simple code, calling and some additional code for all dispatcherss are in single blueprint. For eg. i can add some local function or macro there that lets me debug all dispatchers, then just disconnect it for release. Many pros to it, maybe some cons in multiplayer.

At cost of much higher uglines and spaghetization of code you can make it more flexible:

  • create blueprintable component that assigns and hooks to dispatcher
  • then create blueprint interface, in any actor that needs tyhat dispatcher
  • make blueprintable component check for interface, then call needed functions when dispatcher is triggered
  • now to get any of your blueprints have event triggered by dispatcher, add to it blueprint interface and drop blueprintable component. no exttra code, just use event node from interface.
    Makes code bit more complicated, and those connections to dispatcher etc are hidden so may be confusing.
1 Like

@Nawrot: That’s great and all, agreed. I never use LB myself for the reasons you’ve stated. LB could/should not exist for all I care.

However, this is not stack overflow (obviously :wink: where an answer to a question “how to do it” is “don’t do it”. We cook spaghetti script here.

The question is how to do it - how to hook up a dynamically spawned actor’s dispatcher call to a Custom Event in the LB.

Not whether it’s worth doing or being done right. It isn’t, and OP knows it, admitting it being a nightmare. :wink:

edit: at @OP - refactor if it’s no too late, avoid LB - unless you have that one self-contained level with unique functionality that matters in that one level only.

1 Like

thank you sooo much but it is not so clear for me … I really appreciate if you could link to an example please

I’m currently trying to use GameInstance as a bridge but it doesnt work .

  • I have created a Event Dispatcher in GameInstance,
  • The BP A is calling the dispatcher and in the GameInstance I got the variable passed by BP A

now how can I pass this variable to the BP B once the variable have been changed in the GameInstance?

PS: I forgot to say that the BP B is a Level Blueprint, and even many other Level Blueprint are coming… so they have to listen to GameInstance whenever a variable changes

  • some actor sending data; it has yet to be instantiated


  • Game Instance receiving and sending data


  • below, something spawns ActorAs
  • we register the ActorA’s ED Send Data dispatcher with the Game Instance’s Custom Event
  • you must ensure the data signatures match (here, there’s no data)

  • and the Level Blueprint goes brrrr

1 Like

woow, thankyou… just a second, please let me study your example but I think it’s different that my case (it is a bit more complex because of the different maps) :slight_smile:

I’ll be back in few minutes, I’m just trying

This means that you will need to laboriously include this script in every single level. A somewhat more graceful approach, if must do it this way, would be to encapsulate this behaviour in an actor that is added to each level manually.

But that adds yet another link to the chain…

1 Like

Dont worry about hardworking because this game system is insanely complex (I will upload his announcement soon…)

I’m not sure if this can work in my case. Iwas preparing something to better understand how is the situation :slight_smile:

basically, an actor has been activated after collision. This actor is located in one of the levelmap in the game.
At the same position, after collision, it has to spawn another ActorBP but this has to be attached to an owner otherwise, once that map is unloaded it doesn;t unload this new actor.

To do that I see that the best solution is using the GameInstance, so the collision is calling the event dispatcher in the gameinstance,
can now Level Blueprints for each levelmap read this GameInstance dispatcher?

I’m sorry, just based on your example I dont understand a couple of things.

Actor A the event dispatcher SendData , but is this contains in the GameInstance?
Then GameInstance send another Dispatcher call PropagateData, but where is it?
Then the LevelBPs have to spawn actor . So the last image shows how the all the levelBPs listen to the Gameinstance ED Propagate, is that correct?

Actor A the event dispatcher SendData , but is this contains in the GameInstance?

No. It’s in the ActorA - the actor that sends data. If this actor ever needs to notify the LB that its data has changed, it will call its own dispatcher.

Pressing 1 will call it; if someone is listening, they will hear it. The LB cannot listen to an actor that does not exist, so we need to involve the GI.

Then GameInstance send another Dispatcher call PropagateData, but where is it?

Any actor can call the Game Instance’s Custom Event. When The GI’s event is called, it calls its own dispatcher to send that call further along. The second pic acts like a tunnel. The GI receives the call and sends it further along.

  • ActorA sends data
  • every time ActorA is spawned, we make the Game Instance listen to this ED Send Data (Bind in pic 3 upper right); this can be done in any blueprint
  • when Begin Play in the LB triggers, we make the LB listen to the Game Instance’s ED Propagate Data (pic 4 upper right)

LB listens to GI’s dispatcher, GI listens to the ActorA dispatcher. GI is a glorified message boy, passing info.

1 Like

ok in my case in anytime ActorA is delete… is it the same right? so let me try to apply this