Setting Variables At Runtime Doesn't Work

I’m trying to set the visibility of an enemy’s HealthBar to hidden when they die, but it’s not working and I’m not sure why.

This is my HealthComponent attached to the Enemy:

The HealthBar Widget:

And the OnDeath Logic within the Enemy BP:

I have too many questions regarding the setup - it’s overcomplicated and can (should) be dramatically simplified. Do tell if you’d like a couple pointers.


To the point, though: this sets an enumeration value:

But that’s it, you do not actually hide anything… If you must do it this way, get the reference of the Widget Component and hide it, or get the reference of the Widget and set its Visibility.

Yes I’d love if you could tell me some pointers on how to simplify it. Also any idea how can I get reference of the Widget if it’s within the Health Component?

tl;dr: in case you want to stick to what you’ve got.

Or disconnect the Get Owner node if you want to do this inside the enemy actor.


I’d approach from this angle:

  • create a widget that can accept some data - so we can update it any time:

Here you can update text boxes, progress bar and whatnot. As you already do.

  • add the Widget Component to the enemy actor directly, and set it up:

  • inside the health component:

It detects player damage, processes it and sends an update to the widget.

Hey I managed to fix it with your help. I promoted the widget within the HealthComponent into a variable, accessed it through the Enemy Actor and set the visibility to hidden on death. I’ll try to implement the points that you’ve made though, since it’s a better approach . Thanks again!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.