Event Dispatcher on a Spawned Actor?

I am trying to keep track of enemies dying to increment a level. I am able to give the enemy character its dispatcher when it dies, but for now it only works if I have a character pre-rendered on a level instead of spawned.

Is it possible to have the event dispatcher work on a spawned character? If so, how?

I’m also looking for an answer to this question. Got a variable I’m incrementing when I spawn an enemy, then I’m using an event dispatcher to decrement it when an enemy dies. Works for the first enemy that I already have placed in the level but won’t work for subsequent enemies that I spawn over time. Anyone have an ideas?

What you must know is that “Event Begin Play” won’t “fire” in the spawned actor, when spawned.
So you need to trigger your spawned actor setup from another place.

Here is how I do it:

  • I created a Blueprint that spawns
    certain actors. (BP_Spawner)
  • In each of the spawned actors
    (Hero_Actor) I created a CustomEvent
    (Hero_BeginPlay) which, when fired,
    will do any needed setup for my
    Hero_Actor.
  • In order to trigger that needed setup
    inside Hero_Actor, I hold a reference
    to Hero_Actor inside BP_Spawner. (You
    get that reference, when you use the
    “Return Value” of your “SpawnActor”
    Node.)
  • Now I am able to trigger the
    Hero_BeginPlay Event from within
    BP_Spawner.
1 Like

That will work to get the initial count, but the death event won’t fire to allow the decrement to happen.

I am having the same issue. I have Dispatchers setup to fire events on the level BP whenever one of my NPCs dies or, in the case of boss fights, has taken enough damage to trigger a new phase. The events can be placed in the BP, but they never fire.

What I found to work for me was to bind a custom event in the level to the dispatched event.
So in my NPC blueprint I have an Event Dispatcher called: “CallReinforcements”. I call it after the NPC has had a certain amount of health taken away.

129452-call+dispatcher.png

In the Level Blueprint, when I create the NPC, I then bind this Dispatched Event to a Custom event created in the level itself.

129451-bind+dispatcher.png

When done like this my custom events all work fine. So you should be able to do the same thing. When you create your NPCs, bind their death Dispatched Events to your new custom event in the level BP.

Hope that helps.

… this will fix some scenarios pretty well … some issues … its like addressing spawns from builder … but, my problem is, if spawned actor can “independently” receive an event … from level blueprint or even spawner …

what exactly I want is:

step 1: Spawn numbers of actors and
give them an ID or Name Step 2 :
“BroadCast” an event with an ID or
Name Step 3: The Actor with that name
and ID, responds … … this is my
scenario , not sure how to do it …

I know in C++ you can get a World object or may use some Delegates to make this … but, how in Blueprint thou ?

SOLVED:

1- Assume you have a Spawner blueprint class. This class make numbers of SpawnActors at runtime. Each Actor has a “Public Blueprint variable” named ID, which will assign to a number at “Spawn” time. Also, this class continuously generate random numbers on Tick and assign it to its public variable which is ID.
So in short, it Spawn couple of Actors with ID and has a random number generator on Tick event.

2- You need to add this class (spawner) to stage from editor. It should be there before running game.
3- In Actor class (which you re going to spawn), you need to use “Get All Actors of Class” on Tick and get your Spawner blueprint and put result in an array. It will be just one because you add just one spawner to stage. From that array simply get the first element and easy use public variable of your Spawner which is ID,.

you can use this in scenario like, if that random number match with the ID of you Actor, then you can play some functions thou.

In this approach you don’t need to use ANY event dispatcher.