Using event dispatcher without having a reference to the dispatcher

I want to create an Event Dispatcher on enemy death.
My issue is that enemies spawns AFTER that game has started, thus I can’t make a Bind on event at begin play.
explanation: As I understand, to make the playerCharacter “listen” to the dispatcher I need to have a reference to the enemy and from that reference I need to “Bind on” event.
Since at begin play I do not have an enemy to reference to and since I don’t want use casting during gameplay to create the reference, I have no option to listen to the enemy.

So this is what I am asking. Can I make the player Character listen to the dispatcher coming from the enemy without using casting?

I know I can make use of the the GameMode by making the game mode do the Dispatch.
By casting to game mode at Begin play of the enemy and when an enemy dies he Call an event from GameMode that will trigger the Call dispatcher event.
And the player will listen to the Game mode.

However it doesn’t seem right that the enemy will not dispatch his own death…

I hope I make my self clear …

Bind as you spawn, that’s the whole point of using dispatchers, they work great with dynamic spawning.

Yes, create a Custom Event in the player BP:

When you spawn enemies (anywhere):

The above assumes you have a possessed character. The onDestroyed is a native actor delegate, you can have enemy dispatch something else, ofc. And if you do not want to cast to playerBP every time you spawn (which is a non-issue), cast once onBeginPlay in the actor that spawns enemies and hard reference the player. But that seems unnecessary.

2 Likes

Thank you!
Calling the event from player reference in begin play of enemy_BP looks like the way to go.
I don’t know I haven’t thought about it :slight_smile:

That’s not what was suggested above, though.

Thank you for taking the time to explain and to take screen shots.
I binded the event in the Spawner_BP like you showed and it works like magic!