I previously had a simple piece of HUD that had a button to exit a chair, when pressed it would then move the player away and also remove the hud. That was using Remove Parent. I recently got an error when saving that hud blueprint and now the button doesn’t remove the hud unless I click the button about 20 times. I’m completely stumped.
Hard to say without seeing actual BPs.
One possibility is that you create several widgets instead of one, and your Character or Controller references the wrong one.
You can set breakpoints on nodes using F9. During play the game will halt on a breakpoint if its node is executed. that way you can debug if the button click registers, if the RemoveFromParent node is actually reached, and also on which widget instance. Can you try this for me?
So I tried that and it stopped on remove from parent. I get the feeling that it’s somehow casting that widget 20+ times on top of each other but I can’t figure out where.
Can you confirm if the widget is created multiple times on top of another? You can add a “Print String” node after the button click and use the Display Name of the widget object as input. If you see different names, there are different widgets.
It’s only printing that name so that’s a positive I guess lol. I know I can use remove all widgets but I have other things on screen that I don’t want to remove
Sorry I mixed up GetDisplayName with GetObjectName I think, there is actually a difference. GetObjectName should be the one returning a unique name for comparison.
I think you should definitely debug this further and learn what is going wrong so you can prevent it next time.
That’s still giving me the same result. I’ve tested it and it closes after 24 clicks of the button (For some reason) I don’t really know what could’ve happened but it must’ve been to do with the error I got earlier but I’ll keep trying. Thank you for the help!
Okay so I’ve done a little bit more testing, I swapped out the hud element that’s spawned and it’s definitely spawning numerous times as I can see the text overlapping. So it must be within the blueprint that brings up the hud I’m thinking. [EDIT - I’ve managed to get a fix, the nodes that were spawning the hud came very far down a line of unrelated nodes, so I’ve created a sequence at the start and triggered the add to viewport early on and that seems to have fixed it]
A HUD class is instantiated once per player. You are probably using a For Loop somewhere which calls the method which creates your widget multiple times