How do I hide buttons on a widget due to in-game circumstance?

I’m trying to make an image based health system that cycles through three different colored images (attached to borders) based off of how much HP the character has left. The overall widget works and comes up on screen but none of the images change to hidden no matter the health or what I do.

It should be continually updating the widget from the FPCharacter each time it takes damage so I think the problem is to do with the function that supposed to be hiding it.

I am quite new however so I could be missing something simple.

In update health,do print string to see what is going on.

So it does update correctly and the pathing works in the UpdateHealth function, but it just won’t set the variable widget to hidden or hide it from the screen

Would it happen to be resetting it’s visibility somehow? It shouldn’t be based off of everything I’ve looked through so I don’t know, it’s my first time trying to hide widgets.

How are you adding the widget to the screen?

Through the an Action Mapping in the project settings, I appended it to an inventory system I was using but even when I added it to the viewport through a keybinding by itself it wouldn’t hide either

Could you please show a screenshot of how you’re doing it? We must see how you set the value of this variable:

image

After that damage event (In the BP_FirstPersonCharacter) is triggered its sent through the PlayerMenu widget (which is represented by the last three images, the second and third being everything in the widget event graph, and the last being the function to close it)

I was able to make the menu as a variable by using Create a Widget, setting it, and attaching player controller to it under Event BeginPlay

There is a lot to the inventory system that I cant fit into one post, but I don’t believe that is the issue since even when they weren’t attached it wouldn’t hide itself when I opened it individually

I was able to make the menu as a variable by using Create a Widget, setting it, and attaching player controller to it under Event BeginPlay

Could you show exactly this? Which blueprint is this in? Same as this:

?

Cool. You did not confirm - is this in the Player BP:

image

It would help greatly if you could start confirming the questions :innocent:


And how / when / where do you add it to the viewport? It’s not in the screenshots above.

Both the Event AnyDamage and Event BeginPlay are under BP_FirstPersonCharacter

And my bad after the Input Action it is sent through another widget I called the HUD (which is empty besides this and a canvas in the designer) which then adds the PlayerMenu widget (This holds the HealthIcons I’m trying to set to hidden) to the viewport

Well, this makes no sense - you have 2 widgets.

  • you show this widget:

  • but are trying to change this one:

image

See what I mean? These are 2 separate widgets… Each has a life of its own. You’re asking the widget that is not even showing to hide its… checks notes heart images.


Use the widget you create in the Player BP only. Any other BP can access it quite easily.

I think it’s much, much worse, actually - every time you use this Input Action:

You create a brand new widget:

This means that even if you make changes, they will not be preserved. You’d throw this widget away and make a new one.