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 do I create an 2D Enemy Health Bar?

Ive played with a the HUD a little lately so ive played material instances and 2D vectors but...

Could someone walk me through setting up a health bar for enemy class bps?? When they receive damage the nar pops up 2D I assume facing the player and depletes like on the HUD. Thats what I need...

If anyone can walk mt through that its be splendid. Thanks ;)

Product Version: Not Selected
more ▼

asked May 30 '14 at 08:32 PM in Blueprint Scripting

avatar image

1k 165 164 354

avatar image DizzyWes ♦♦ STAFF Jun 04 '14 at 03:37 PM


Have you taken a look at the Content Examples and the HUD map, there's a health bar in that example. There's also a couple threads on AnswerHub and the forums that may help you, HERE and HERE. As for the actual Health system, there's a post HERE too.

More documentation will also be coming soon regarding the Content Example and how the HUD was set up.


avatar image AttemptD Jun 05 '14 at 06:22 PM

Well the health bar was going to be floating above the enemy....instead of being on the HUD.

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

4 answers: sort voted first

Here's a very quick and dirty example one could take:

Add two boxes to your character, one box for health the other for max health (e.g. a green box and a black box).

alt text

I'm not sure if you want this for a player character or an enemy, but this should get you started.

Scale the health box based on your damage system (for testing, I just hooked it up to F key press to scale it).

alt text

The Blueprint shrinks the bar by .1 then moves the bar along the Y so that it lines up with the Max Health bar behind it.

While there is much more to do with this (branching to see if health is at 0, hooking it up to a damage system as I said, tweaking the amount the bar scales, etc.)... this might give you some ideas.


healthbar.png (155.2 kB)
more ▼

answered Jun 06 '14 at 03:20 PM

avatar image

DizzyWes ♦♦ STAFF
5k 145 64 206

avatar image AttemptD Jun 06 '14 at 04:00 PM

That was excellent! ! Thanks a million. :)

avatar image Virtuosic Kitty Jul 31 '14 at 07:54 PM

This is fantastic. I am currently using this method. Just a question though, is there a way to make the material change once it has reached a certain size? so like if its 50% it goes Yellow and then 20% Red?

avatar image jfaztk Mar 26 '15 at 04:43 AM

You'd replace the mesh, I'd assume.

avatar image rtro92 Nov 08 '15 at 09:26 PM

You can change the color by binding the 'Fill Color and Opacity' to a function. Feed the health/percent into it and do your logic in there. That will output green to yellow to red, etc.

avatar image shotty46290 Sep 14 '16 at 05:27 PM

A easier way would be to drag in your box, and do a check based on how scaled it is, and use the set material node to change its color

avatar image npcSwords Sep 19 '16 at 07:49 PM

can you share how you would do this?

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

In 4.6.1, you can just attach a widget to the Actor. Tesla has a nice video that steps through it -- I've tried it myself and it works perfectly :)


more ▼

answered Jan 26 '15 at 04:12 AM

avatar image

153 16 18 34

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

Look at the objective system in the content examples, and try combining that with the health bar example. That should be all you need.

more ▼

answered Jun 05 '14 at 07:06 PM

avatar image

Axtel Sturnclaw
73 4 8 12

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


I just got done working on something myself. Personally, I prefer to use a billboard, but the same logic applies. We're still working with the Y scale. Scale the bar however you feel - In my example, I've used 96. Keep that number in mind.

You'll also need to declare some basic variables. 1. Healthbarfullscale - Basically getting the default "96" 2. HP Increment - the value we're feeding into our billboards Y axis to scale it.

You need 3 Materials. 1. OK Health 2. Medium Health 3. Bad Health

alt text

On begin - You're going to want to reference that Y scales initial value.

alt text

While I'm testing, I find it's useful to print strings as visual feedback to make sure I'm pulling the right value through.

Then, on take damage - add a sequence. Damage mechanics go in first. Then, you rescale your bar.

alt text

This works by getting your current monster HP as a percentage of the full HP, and scaling the Y axis by that factor. The value returned is fed back into the element. So at 67% health, your bar will be 67% of that initial "96" that you got.

Once you've scaled, the third step is to see if we need to give visual feedback about the condition. Basically I can split 96 into 3 segments. 0-32, 33-64 and 65 to 96 - nice 32/32/32 chunks.

alt text

I check first if I've gone below 65. If I have, I then check if I'm below 33. If I'm not below 33, I go yellow, if I am, I go red. If I'm still over 65, then I do nothing, and stay at my default.

Once we've built this, let's look back.

Key things -

I always set the scale before the colour. You'll notice the scale element draws the same material on "make" that it pulled from "break" - essentially - "I will always use whatever colour my bar is set to, until I need to change it".

My Float/50 - My initial monster HP is 50 in this example. Current HP/50 returns a factor of 1. This is the easiest way to scale, as you can then just use this as a multiplier.

This bar scales inward from both ends.

You can apply the same logic as the original answer to mitigate if you want. Kick it along the Y axis transform by using a product of your multiplier, and the current bar Y scale to come up with a value to feed into the transform.

Easy Peasy.

more ▼

answered Nov 11 '14 at 10:25 PM

avatar image

51 10 9 13

avatar image Dusaral Nov 12 '14 at 04:36 PM


With the latest version (4.5), you can do that by using UMG (Unreal Motion Graphic) ;). It's pretty simple to use. There's tutorial you can check.

avatar image tomtomftw Jan 26 '15 at 12:52 AM

is this in 4.5? or 4.6? im runnin 4.5.1 and cant seem to find how to attach the umg to the char.

(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