Why are widgets so wonky?

So the situation is an actor bp. I don’t have any problem creating the widget from a begin play. However its in the getting rid of it when I need to that is not working out. Its a player HUD widget. When the player loses both lives it needs to remove so the continue widget comes up (not overlayed).

Before I need it I check with a branch the “P00 Lives counter” integer stored in the game instance. If this is 0 then it should remove the widget. At this branch if I use a greater than zero, the continue widget comes up fine but overlays the player HUD. However if I use a less than, and set it to either 1 or zero, the process seems to work, but it triggers after just one life is lost.

Any idea? Thx

Sounds like a scripting logic issue rather than widget issue. Post the logic script, widget creation + referencing, and widget removal.


If you’re 100% certain you’re doing it correctly, set up breakpoints and step through the script.

1 Like

Greetings @Everynone, hope all is going well your way. Here is the information you seek.

Here is the effect of that current node.

Image5

Does this part of the script execute?

image

If it does, you might be adding more widgets than you think, and they become orphaned in the viewport, or the `Garbage Collection’ is unable to scoop them up. Count them on Tick:

If you ever get more than 1, there is an issue elsewhere.


Also note, we remove it from viewport, but never clear its reference variable. The widget will not be Garbage Collected and removed from memory.

1 Like

You were right. A get all widgets of class proved effective. So it must have made more than one instance of the widget some where. Thx Everynone!

If you have a destroy / respawn cycle here (if I am reading it right), I’d investigate the chain of events first. As in: at which point does the 2nd unwanted HUD comes to play? Put a breakpoint on it.


Another way to handle it is to not associate a persistent HUD with entities that get destroyed. Not sure if applicable here, perhaps you want/must create/remove widgets. But consider the HUD BP class - a framework singleton accessible from anywhere via the Player Controller:

image

It can be effectively used a widget manager. Think of it as of a hub for all UI related things that keeps tracks of widgets. It can also do some funky drawing stuff no other BP can.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.