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"

UMG Healthbar is shared for multiple enemies

I have created a health bar in UMG for multiple enemies. It works great for the first enemy. The problem is that the other enemies share the same health bar. So after the first enemy dies the other enemies have their health bar already depleted.

I'm sure I'm not going about this the right way. So my question is what would be the best method to create enemy health bars that can work for multiple enemies and be independent of each other?


Product Version: Not Selected
more ▼

asked Feb 13 '15 at 05:15 PM in Blueprint Scripting

avatar image

43 3 5 9

avatar image JeromeParent Feb 14 '15 at 07:49 PM

How are you creating the widget? Is it a Widget Component in the enemy blueprint?

Where is the value that controls the health bar status?

avatar image JeromeParent Feb 15 '15 at 12:34 AM

Can you show a screenshot of the graphs that modifies the health bar (both where the health var on the Pawn is modified, and where your Widget does something with it)?

Each instance of that Pawn has its own instance of the health bar and health variables, so its probably a simple error somewhere in your graph.

avatar image Tobbo Feb 15 '15 at 01:09 AM

I actually got the health bars to act independently now. The problem was the the health bar for some reason was dictating the health of the pawns, instead of the other way around. It was an issue with my graph and after I changed the order of some variables it started working as it should.

Even though they are acting independent the health bar is not updating as often as it should. For instance I kill the first pawn and move to the second pawn. The 2nd pawn has its health bar depleted until I cause some damage and then it adjusts and acts as it should.

Anyway, I'm going to play with it some and see if I can't figure out how to update the health bars properly. Thanks for the responses JParent and GeeksGoneBad. I do appreciate it.

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

2 answers: sort voted first

I would think each enemy would have to instantiate their own UMG Widget in their start up? so in the enemy blueprint there'd be a "Create Widget" in their construction or something like that - sorry I don't have the engine open right now but it's got to be something like that - hope that gives you an idea ;)

more ▼

answered Feb 13 '15 at 07:55 PM

avatar image

61 6 9 13

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

After looking around at different forums, I came with the solution that worked for me (Referencing this forum: https://answers.unrealengine.com/questions/194545/enemy-2d-health-bars.html).

On "event tick" I fire my "HealthBarUpdate" function, which updates the percentage of the enemies healthbars. The healthbar is a 3D Widget in the enemy blueprint (picture below). alt text

This is how it looks above my enemy (picture below).

alt text

Hope this helps! :)

more ▼

answered Jan 19 '17 at 08:05 PM

avatar image

11 3 3 5

(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