x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.8
Tags:
more ▼

asked Nov 05 '15 at 02:30 AM in Blueprint Scripting

avatar image

The1456
1 3 4 3

avatar image CKong Nov 05 '15 at 03:09 AM

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?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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:

alt text

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

hearthealthbar.png (225.7 kB)
more ▼

answered Nov 05 '15 at 07:28 PM

avatar image

ScottSpadea
9.6k 320 205 450

avatar image arthursgqg Feb 08 '16 at 09:02 PM

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. Thanks

avatar image ScottSpadea Feb 12 '16 at 09:35 AM

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.

avatar image Sdalvik Feb 06 '17 at 01:51 AM

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)?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question