# How to bind Health Bar Widget to an enemy

**URL:** <https://forums.unrealengine.com/t/how-to-bind-health-bar-widget-to-an-enemy/474719>\
**Category:** UI\
**Tags:** health, health-bar, unreal-engine, enemy, Widget, question\
**Created:** [November 19, 2020, 12:48pm UTC](https://forums.unrealengine.com/t/how-to-bind-health-bar-widget-to-an-enemy/474719 "2020-11-19T12:48:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_a372ce32](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a372ce32](https://forums.unrealengine.com/u/anonymous_user_a372ce32)\
**Post date:** [November 19, 2020, 12:48pm UTC](https://forums.unrealengine.com/t/how-to-bind-health-bar-widget-to-an-enemy/474719/1 "2020-11-19T12:48:12Z")

</div>

Hi, I’m trying to connect a Widget (which is shown above an enemy) that indicates Health.  
The point is, I can’t find an enemy reference node.  
As an example I’ve connected “Get Player Character” so all Widgets (Player and Enemies) point to Player’s Health.  
Is there a specific node to indicate “self” (intended as the Enemy) or what can I do? Thank you all.

 ![322475-immagine.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/9/2/e920b029822a8fcec9c5422237941807f9910dce.jpeg)

 ![322476-sharedscreenshot.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/a/d/6ada1786ba27338a238a8599ce0434e014bcec13.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 19, 2020, 3:23pm UTC](https://forums.unrealengine.com/t/how-to-bind-health-bar-widget-to-an-enemy/474719/2 "2020-11-19T15:23:23Z")

</div>

2 questions:

- are you using a widget component?
- do you need to update the enemy health bar _every frame_ (usually 60 times per second)

Binding functions (what you have atm) is generally not such a great idea and much better, event driven, approaches really shine here.

Do tell.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a372ce32](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a372ce32](https://forums.unrealengine.com/u/anonymous_user_a372ce32)\
**Post date:** [November 19, 2020, 3:33pm UTC](https://forums.unrealengine.com/t/how-to-bind-health-bar-widget-to-an-enemy/474719/3 "2020-11-19T15:33:57Z")

</div>

Thank you for answering! Yes, I’m using a widget component and I need to update enemy health only when its health is affected. Any suggestions?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 19, 2020, 4:12pm UTC](https://forums.unrealengine.com/t/how-to-bind-health-bar-widget-to-an-enemy/474719/4 "2020-11-19T16:12:10Z")

</div>

As a general rule of thumb, the less you do in the widget, the better. Here, it’s the actor that drives the widget behaviour and _feeds it data_, rather than widget referencing the actor and trying to _pull the data out_ of the actor.

* * *

`Remove Binding` from the `Progress Bar` and add this in the enemy blueprint:

 ![322497-screenshot-2020-11-19-160325.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/5/655f1744864e8c8e8308f4db2258ffc13d0ea184.jpeg)

From the top:

- `Begin Play` creates a reference to the widget embedded in the component so the owning actor can access it easily
- `Event AnyDamage` fires when damage is applied to this actor
- we deduct health
- _current HP_ / _Max HP_ is the percentage of hit points left and can be sent to the progress bar - `Set Percent`
- when currentHP is zero or less, we Destroy Actor (optional ofc)

* * *

This way, this script runs only when the enemy receives damage rather than _all the time_. This may not mean much with a couple of enemies but all those Ticks quickly pile up.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a372ce32](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a372ce32](https://forums.unrealengine.com/u/anonymous_user_a372ce32)\
**Post date:** [November 19, 2020, 5:00pm UTC](https://forums.unrealengine.com/t/how-to-bind-health-bar-widget-to-an-enemy/474719/5 "2020-11-19T17:00:19Z")

</div>

It works, thank you very much!

---

<div class="post-metadata">

**Author:** ![vpox78](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vpox78/32/905768_2.png) [@vpox78](https://forums.unrealengine.com/u/vpox78)\
**Post date:** [September 4, 2024, 3:33am UTC](https://forums.unrealengine.com/t/how-to-bind-health-bar-widget-to-an-enemy/474719/6 "2024-09-04T03:33:59Z")

</div>

very thank you 🙂 still helpful
