How to upgrade health using hearts system
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.
asked Nov 05 '15 at 02:30 AM in Blueprint Scripting
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
Follow this question
Once you sign in you will be able to subscribe for any updates here