Custom HP bar? A regular object has not enough options

I’m making a custom HP bar thats why a regular preset object doesnt fit to me. How to make a picture that becomes shorter depending on % HP of a player? For example, it should be always 100 pixels wide - no matter if a player has 100 or 10000 max hp.So if a player has 50% of max hp the picture is 50 pixels and so on.

You can use your own graphics with the custom object, but regardless:

  1. Make whatever bar you want as the type of object you want (normally sprite or 9-panel).
  2. Ensure it is the max length you want.
  3. Then set it’s width scale via events. You’ll want to set it’s scale to YourCurrentHPVariable/YourMaxHPVariable. It’s up to you to create and maintain those variables, but if your character has 75 out of 100 HP, you’ll be saying “Set Width scale of MyBarObject to: 75/100” (Which results in 0.75 width scale, or 75% it’s normal size).

The bar will adjust accordingly. There’s also an example of this in the engine itself called “Health Bar”.

Note that this is basically what the health bar object does, and you can just select any of those healthbars and update the object graphics in the properties.

1 Like