Download

Trouble with EventDispatchers/Delegates with Child/Parent Classes

I’m using 4.22

My Goal: Have a LivingCreature super class that holds all my players and enemies. Have it contain a “CreatureHasDied” event dispatcher that announces to all other living creatures when one has died.

How I’m trying it:

LivingCreature has an Event Dispatcher called “CreatureHasDied”

BaseEnemy, a child of LivingCreature, Binds to event “CreatureHasDied” with it’s own custom event CreatureDied. When an enemy that is a child of BaseEnemy dies, it calls BaseEnemy::CreatureDied. I want it to be announced to all the other creatures so if they are tracking that creature for some reason, they can remove it from the lists.

For some reason, my bind just fails. Calling LivingCreature::CreatureHasDied does not Announce to Enemies that are children of BaseEnemy, when BaseEnemy should be bound as a listener to that event.

I’m just doing someone majorly wrong. Can someone maybe show some examples of a similar system or tell me what I might be missing?

Thanks,

HyenaGames - Chris Vogel