Firing an event from an enemy to update the player UI

Hi everyone, been at this for quite a while, Google has lead me in some interesting directions but I’m still not even close to accomplishing what I’m trying to do here.

The set up is fairly simple: there’s a couple AI Character pawns with health and hit collision.

I have a few enemy archetypes all based off of what I name “BP_BaseEnemy” which all enemy characters base off of and handles their internal health management and decision making when firing their Death routines.

In the BP_BaseEnemy blueprint class, I’ve created an event called “ReportDeath”, and the Death routine calls it.

Where I am having explicit issue is setting up the listener for the event in a Widget Blueprints graph.

It will not let me Cast To BP_BaseEnemy without a Target, but anytime I try to pin it on an Owner node, it keeps asking for a Target proper ad nauseum. Of course this causes the BP compiler to error out without a Target.

I just want this UI to listen for a ReportDeath event to be fired.


Back in Unity, I understand that the Outlined hierarchy had everything to do with how who and what and to where events fired would bubble up too. When I peruse the UE4 docs and watch examples, no one makes mention of this kind of limitation to the event system here. This leads me to believe I can fire an event from pretty much anywhere a d I should be able to set up a listener pretty much anywhere.

How correct is that assumption? Am I way off?

I’m not sure how complex you want this to be, but an option would be to have a reference to your widget set on the player controller. When the widget is created, its BeginPlay should go to the Controller to get set into that variable.

Then, in your enemy base class event you can:

  • Get Player Controller
  • Cast to your controller with the widget variable
  • Get the widget and call its event to trigger the UI update

Is this a single player game? Performance not really an issue? If so this setup is fine, but a networked game will need a more complex system to get the correct controller, and using a Dispatcher is possible but you need to Bind it to the Event using a reference. The way I’ve mentioned is an ok method, but in a large game you may want something more efficient.