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 display health bar on hud when picking up item

Hi everyone, I have a widget blueprint setup with a health bar. I want the health bar to be unvisible in level 1 and 2.

In the 3rd level the health bar should become visible but only when i pickup a power-up called Health for example.

How can i implement this in blueprints?

any help would be greatly appreciated.

Peace

Product Version: UE 4.14
Tags:
more ▼

asked May 11 '17 at 02:39 PM in Blueprint Scripting

avatar image

gandalfini25
20 9 5 10

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

If Im understanding your earlier comments correcly mabe you havent added your hud widget to viewport? This would allso get you a reference of that instance whereby you can directly "talk" to that widgets plueprint as the previous answer hinted at.

you can construct widgets in the "begin play" of the player controller or the level blueprint for example.

alt text

more ▼

answered May 14 '17 at 09:33 AM

avatar image

Kipplinger
376 12 5 17

avatar image gandalfini25 May 14 '17 at 06:20 PM

I already added event begin play to hud widget to viewport. I have set it up in the third person HUD.

I don't know how to make something visible on the HUD when i have picked up an item.

For example i want the health bar invisible on the HUD but from the point i pickup a health pack the health bar should become visible that's what i'm trying to figure out.

I have a reference to the hud. So the blueprint i have should normally work but it does not. ( The blueprint i have is the same as the the previous answer )

avatar image Kipplinger May 15 '17 at 09:20 AM

aha well itc a simple solution that could work for you is to make a custom event in your hud widget that toggles the visibility of your "healthbar" component. Then fire that event from the controller for example, (you do this by dragig a node from a "hud reference" node, as I described earlier).

In you have more questions I would recommend looking for some tutorials that describe "casting" and communication between different blueprints, since that is in effect what you need to do.

gl ^^

avatar image gandalfini25 May 15 '17 at 05:19 PM

Thank you for the answer. I have found the solution to my problem.

In the widget blueprint i set the health box to hidden, then in event graph of the widget i created a "custom event" and named it "Toggle Visibility" ( red node ).

I connected that to "set visibility" ( target is widget ). Set it to "visible". In the target i have called a "get health bar" and connected it to target of "set visibility".

After that i created a powerup blueprint, i have added a "sphere" and a "sphere collision" component. I clicked the "sphere collision" and in the details under events i clicked on "oncomponentbeginoverlap".

Connected "oncomponentbeginoverlap" to a "get all actors of class" node, On the "out actors" node i connected a "get" node, after that i connected tha "hud reference node" and after that i connected the "toggle visibility" ( blue node ).

This worked for me. Thanks for the help!

avatar image Kipplinger May 17 '17 at 08:11 PM

The gest all actors of class node is kinda heavy, (for a single node at-least), getting the reference to the hud widget instance some other way is better for performance - but don't fret over it, its more important to get progress and learn imo. Could you maybe mark the question as answered tho? It would clear it away from the un-answered questions. ^^

(comments are locked)
10|2000 characters needed characters left

The easier way would be to control the visibility behaviour of the health bar via blueprints. Just make sure that in the blueprint where you check the condition 'health bar can be shown' you have the HUD with the progress bar in it in a variable, that way you can just get that variable, from there get the health bar (I'm assuming it's a progress bar), and from there set visibility. Kinda like this: Can Health bar be shows?

more ▼

answered May 11 '17 at 06:03 PM

avatar image

Erik 256
3 1 2 3

avatar image gandalfini25 May 11 '17 at 07:27 PM

Thanks for the answer, it is so close to where i want to get it. How do i create the HUD variable?

Which node do you use before the branch to trigger the blueprint?

avatar image gandalfini25 May 11 '17 at 08:24 PM

Also is your "can health bar be shown" boolean variable checked or unchecked?

avatar image gandalfini25 May 11 '17 at 08:26 PM

And where did you set this blueprint up? Is it in the level blueprint or somewhere else?

avatar image gandalfini25 May 13 '17 at 11:46 PM

If someone knows how to make my health bar on the HUD visible when i pickup an item please let me know as soon as possible, i'm still stuck on this.

I need to see a full blueprint on how i can set this up or a good step by step explanation on how to set this up in blueprints. Thanks in advance for anyone responding.

(comments are locked)
10|2000 characters needed characters left
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