HP/Mana Bar with UMG & C++

Hey,

I want to create a simple mana & hp bar for my character. I know how to do it with HUD/Canvas, but I think UMG is better for UI things right?

My Problem now is, I have no idea how to use UMG. Beside the design oft the mana/hp bar i want to do everything in c++, (progress etc.).

Until now I’ve seen that there is something called a Widget Blueprint, where I can drag & drop a Progress bar and this has to be added to the Viewport, but how do i get this Widget Blueprint from C++ to add it to the viewport?
I’ve tried using the ConstructorHelpers and get it by it’s path, but somehow it doesn’t work.

Can anyone help or has an better solution to create such an UI?

Hello,

You can create Health bar using Slate UI Framework in C++ (SCompoundWidget class in particular).

Slate is a custom and platform independent user interface framework that is designed for effective creation of user interfaces for games and custom tools.
If you like to learn more about Slate, please go here:

For an example of health bar implementation, please go here:

In addition, if you like to learn more about buttons creation and drawing in HUD, please go here:

Hope this helped!

Have a great day!

I already know the second link, with canvas and code its easy to create such a bar, but isn’t UMG better or more preferred for such things?

UMG is easier to use and has the same functionality as Slate, but in some cases you may need to use Slate since it provides more possibilities for customization.

Canvas is convenient for intermediate stages of development, when you need to implement some approximate test functionality. However, for a final version UMG is more appropriate.

and what about using canvas?

ok thank you for the answer :slight_smile:

You are welcome! Good luck!

UMG is just a more friendly way to implement SLATE Sleicreider, its like using umg but with code, umg was made for designers to be able to make UIs without having to know or use code.

*However Slate has more possibilities in creation, since it uses code and so you can pretty much do whatever you wish, while umg is more limited.