How to make Dynamic HUD elements?

Hi, I had various hud elements controlled with their own widgets and blueprint ground on my character. Things such as a Stamina bar and flashlight battery bar. Right now i have them drawn with an event beginplay, but i would like to make them dynamic and have them only show up when the bar is less than 100%. I’ve tried using a branch and set the conditions to draw when less than 100% but with the even tick or event beginplay it didnt work.

Take a look on the widget documentary page to see how you can bind widget properties to values but it should also work by setting them with an event. If you post a screenshot of your blueprints maybe I can find the problem.

Ive been trying to work it out, I got it to go from not visible to visible using this. the branch is connected to the event tick. but the only command to remove widgets from view port will remove them all. I dont want to that since i have a stamina and health bar that I want to work independently.

Thank you so much, after trying an hour to figure it out. I finally got it working.

Ah, I see your problem. I would not add or remove the widgets the better way is to just hide them.

Create your HUD just once and store it in a variable. In you HUD class you create an Event for Show/Hide Flashlight Power, and call Set Visibility on the widget you want to hide, then you can call this Event from your pawn when you want to show or hide it.

Good that it works but I have to make a suggestion to make it look nicer, I do the check if the power is below 100% in the pawn, and pass that result to the HUD and only fire the event when a change occurs. Maybe later you want to hide the bar because of other reasons.

There is also the operrtunity to bind a function to the get visible property of the bar and do the checking there, it doesnt make any differents if you call the event every tick anyways.

that was the only way i was able to get it working, i couldnt put the power check and change visibility on the player controller. I wasnt allowing me to access the hud widget with the set visibility command. also the call is on the event tick.

in the end this is what i got, for anyone else who sees this and has the trouble i had

Its just cosmetics as it seems to work but what I meant was keep the set visibility inside the HUD and give that Event a parameter and do the checking in your pawn and pass the boolean to the HUD event.

Just add the stamina bar and health bar where u want to put them and then create a binding from the progress tab in the details panel of the bars