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

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:

137627-health+bar+shown.png

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?

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

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

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.

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.

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 )

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 ^^

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!

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