I needed help for heath bar

I use Gdevelop for a year now, but I want to add health, and I followed the lesson again because I haven’t use Health bar for a LONG TIME! so, I followed exactly what the lesson wants me to do but it did not work…

I did not get it why it did not work, I added everything. I added the extension, I added behavior, I added, “Interface” and I even added a code…

can someone help me out.


HP bar shrink
Bar Width/Object.Health::MaxHealth()*Object.Health::Health()

I Don’t get it, can you send a screen shot

Look i opened my bar image in paint but any program will do even hovering over the file will display you its size

It says my bar is 200 pixel wide 16 pixel tall

But here we care only for width so 200 is only value that matters here
Now since i use health extension (same as you do) i simply use formula
To change width of my health bar object
If i would use variables i would need 2 of them on my Player HPMax and HP
And now formula would look like

I put this action in event WITHOUT any condition so it is updated each frame

And now bar will shrink if you made event to subtract health from player via health extension action or if you would subtract form Player.Variable(HP) if you would go with variables instead

Avoid using fixed numbers in the formulae; if you change the size of the image, then you’ll be stuck finding and replacing all events that refer to the old size. Use the object properties and functions instead (Width() in this case).

However, in order to resize it you’ll need to store the original bar width in a variable. Otherwise, the resize will be based on the health bar’s current width. So, at the start of the scene set:

health_Bar_Object.Variable(original_width) = health_Bar_Object.Width()

and use it in the formulae:

health_Bar_Object.Variable(original_width) * (current_Health / max_Health)

thanks @MrMen and @ZeroX4 i manage to work😊