Have you check if all your variable got the right variable initialize from the start, especially the Health variable? In healthwidget.jpg, i see you have set your character Health equal to MaxHealth, which mean you set your character Health to 100? Also, can you post the screenshot of the function which you use to update health widget with?
I am with a group attempting to make a game that has turn based attack and defend system. Our health system is hearts instead of a health bar, but the picture of the hearts are used on a progress bar. With the progress bar we have it binded to a script that gets the health percent. What we are wanting is to start out with 3 hearts (which would be 60% of a progress bar). But when I set the health to 60 out of max health of 100 the gui picture of 5 hearts still shows. The player takes 20 damage. When the character takes damage of 20 it takes away 1/3 of the 5 heart gui. How do i make 2 of the 5 heart gui not be visable until the health is upgraded by one heart.
have you tried making a wrap box and using a loop to add widgets?
make 2 widget blueprints, and delete their canvases. add a wrap box to one, and an image to the other. bind the image’s brush to a function. make a SlateBrush variable that is set to editable and exposed on spawn, and connect it to the GetBrush function’s return value.
then in the other widget, the one with the wrap box, you can use forloops to create the image widgets, and add them each as a child of the wrap box.
if you add your wrap box widget to your main HUD widget, with dimensions of 335 x 100, it should look like this:
and if for some reason you want to convert health from a percentage of 100 to a range of 5 hearts, you could just divide the health by 100, then multiply by 5, and round down.
( Health / 100 ) * MaxHealth = NewHealth
( 60 / 100 ) * 5 = 3
Hello Scott, could you show more imagens about your explanation? Because I’m new at the Unreal Engine, and I got a little lost in the end, when you said to add my wrap box to my main HUD Widget.
to add a widget to another widget, you can open the widget, make sure you are in the designer tab, and on the left there should be a palette list and a hierarchy list. just drag elements from the palette list to the hierarchy list, to add it to the tree of ui widgets. or drag from the palette list to the canvas.
It’s a bit late, I’m new, but how can I update the health bar with hearts to show one less heart when clicking on F (or taking damage)?