# How do I make my progress bar decrease with integer-based health?

**URL:** <https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058>\
**Category:** Community & Industry Discussion\
**Tags:** health, damage, float, integer, unreal-engine, question\
**Created:** [April 17, 2021, 5:37am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058 "2021-04-17T05:37:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 5:37am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/1 "2021-04-17T05:37:19Z")

</div>

Hello. I have created a simple integer based health/damage system where the enemy has 1000 health, and the player deals 100 damage per hit. However, the health progress bar widget doesn’t decrease until the enemy goes from 100 to 0 health. This is because any value over 1.0 is considered more than 100% of the progress bar. How can I change it so that it detects that 1000 health is 100%, 500 health is 50%, etc… Is there any way I can override the progress bar’s percent progress so that it has a larger value range than 0.0 - 1.0? If not, how else can I fix this problem?

---

<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:** [April 17, 2021, 6:01am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/2 "2021-04-17T06:01:21Z")

</div>

You need floats for that:

 ![336154-screenshot-1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/e/7/6e7f7c9983a010c9a6ed1b0a15e0754c6189f84f.png)

Any of those 2 will work, there might be more ways…

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 6:36am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/3 "2021-04-17T06:36:58Z")

</div>

I’m not exactly sure where to add this in. Would it go in between the subtraction node and set enemy health node?

 ![336158-image-2021-04-16-233645.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/2/1d200936898187cdf11e05ac98e0af191a3fad09.png)

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 6:37am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/4 "2021-04-17T06:37:51Z")

</div>

Or do I need to add it to the BeginPlay event and set the health there?

---

<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:** [April 17, 2021, 6:39am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/5 "2021-04-17T06:39:56Z")

</div>

But your health is not integer… it’s already a float. Divide current by max and you have a 0-1 range. Send that to the widget progress bar.

---

<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:** [April 17, 2021, 6:40am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/6 "2021-04-17T06:40:50Z")

</div>

You can do the division when you send it to the widget, or even in the widget itself.

 ![336161-screenshot-5.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/c/e/2ce1c037903d73393174dbf755779aa2f062f8db.png)

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 6:43am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/7 "2021-04-17T06:43:53Z")

</div>

I changed the health back to a float because your initial comment said I needed floats for it. By “send it” do you mean cast it to the progress bar widget?

---

<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:** [April 17, 2021, 6:46am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/8 "2021-04-17T06:46:35Z")

</div>

I don’t know how you organised you widgets but if the health bar belongs to the enemy, there should be no need for casting.

Are you using a widget component or a normal 2d widget?

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 6:47am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/9 "2021-04-17T06:47:33Z")

</div>

A widget component

---

<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:** [April 17, 2021, 6:50am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/10 "2021-04-17T06:50:13Z")

</div>

![336162-component.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/b/6/7b63882ca33dbf3374c28599b351f92f61f088b8.png)

It’s this then.

---

<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:** [April 17, 2021, 6:54am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/11 "2021-04-17T06:54:29Z")

</div>

Ah, I mean you can convert int to float and back but it can be inconvenient - extra nodes are needed. You need floats for fractions. So you main health can be an int but it need the decimals for the progress bars, alphas and many other things.

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 6:57am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/12 "2021-04-17T06:57:09Z")

</div>

Okay. What widget is supposed to be the target for the “Get User Widget Object” node?

---

<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:** [April 17, 2021, 7:02am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/13 "2021-04-17T07:02:56Z")

</div>

The widget component that the enemy is using. You said you were using a widget component.

 ![336165-screenshot-7.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/5/ab50c4b0e3bf8d9e73193d75dbcb811b398a1648.png)

Widget component hosts a traditional widget inside. We give the enemy actor full access to the health bar widget. So we can push in new health values and update the widget only when the health values changes. Quite an efficient approach.

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 7:04am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/14 "2021-04-17T07:04:30Z")

</div>

If I set it up like that, I can’t execute both event paths after those nodes.

 ![336164-image-2021-04-17-000421.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/6/4d6a38a5a86f9b54686d93ec87c0f066c49049c9.png)

---

<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:** [April 17, 2021, 7:09am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/15 "2021-04-17T07:09:32Z")

</div>

You don’t want to hook it up here. Do look at my screenshot above carefully.

Create the reference on Begin Play first - **and only once** - as I do, the top bit of my screenshot. Then you’re free to update the widget whenever you want using just the reference.

Also, if you ever need to have more than one execution node:

![336166-screenshot-8.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/b/4/db448c862cfba1c56e75e9a6bcebcfd19e475e4e.png)

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 7:19am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/16 "2021-04-17T07:19:41Z")

</div>

Is this looking right?

 ![336167-image-2021-04-17-001925.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/7/7c7a11038ccee2a71d77d54c791898ffa79de1b0.png)

---

<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:** [April 17, 2021, 7:25am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/17 "2021-04-17T07:25:39Z")

</div>

No. The division is reversed. Current / Max

But you don’t need to call Update Health (don’t connect it for now). We’re already updating the progress bar…

I don’t know what you do in that function, you might be overriding the value you set in the progress bar.

---

<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:** [April 17, 2021, 7:29am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/18 "2021-04-17T07:29:35Z")

</div>

Just realised I posted an identical setup half a year ago:

> **[How to bind Health Bar Widget to an enemy](https://forums.unrealengine.com/questions/996600/how-to-bind-health-bar-widget-to-an-enemy.html)**
>
> 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...

Old habits die hard.

---

<div class="post-metadata">

**Author:** ![Chief\_Man](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Chief\_Man](https://forums.unrealengine.com/u/Chief_Man)\
**Post date:** [April 17, 2021, 7:30am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/19 "2021-04-17T07:30:18Z")

</div>

Okay, I changed the division. This is my update health function:

 ![335969-image-2021-04-15-004421.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/0/e/30ea7063763eaeda767f14f251285588fd4f51e7.png)

---

<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:** [April 17, 2021, 7:31am UTC](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058/20 "2021-04-17T07:31:54Z")

</div>

And here’s an example similar to yours that uses a custom event in the widget:

> **[How to Set Progress Bar Fill Image That Changes With Fill Percent?](https://forums.unrealengine.com/questions/897511/how-to-set-progress-bar-fill-image-that-changes-wi.html)**
>
> I’m trying to set my character’s healthbar to consist of three images that correspond to his health level (a green image for 40+ health, an orange image for 20-40 health, and a red image for less than 20 health), but this is proving to be frustrating...

You’d need to add the widget component bit to this.

[Next page](https://forums.unrealengine.com/t/how-do-i-make-my-progress-bar-decrease-with-integer-based-health/482058.md?page=2)
