UI: Remove from Parent doesn't work in Blueprint Class

I create a UI when the Player enters a Box Trigger, and remove it when he leaves. The code works fine in a Level Blueprint. When I ported the code to a Blueprint Class, the UI is creaed as expected, but it isn’t removed.

I have checked for others questions here https://answers.unrealengine.com/questions/topics/remove+from+viewport.html, but most people code inside the Widget Blueprint.

The answer that get the closest to my case is that one: How do i remove a widget from view port using trigger boxes - UI - Unreal Engine Forums

And it suggests what I was already doing in the Level Blueprint.

Level Blueprint, remove works:

Blueprint Class, remove doesn’t work.

In the Blueprint Class I even watched the Widget Reference value and it was set correctly, I also put a debug in the end, and the text was printed on screen, so it reached there.

Thanks in advance!

Did you completely remove the creation of the blueprint in your level? If so, can you try creating the widget in the begin play instead of doing it every overlap? I suspect that the widget is created multiple times and added to the viewport. So when you remove it from parent, it only removes the last instance created.

1 Like

Thanks for your answer. I actually just created one UI in the OverlapBegin, so I don’t think there’s more of them in the level.
Also, I created and remove them because the UI is specific to each region of the level.

Hey there, i would say that should work. Try checking if widget reference is valid on the overlap end, also try to set an owning player to the get player controller to see if it makes a difference.

You drag a wire from Widget Reference and type is valid. when you create the widget you can set the owning player controller.

Thanks for you answer.

  1. I’m quite new to blueprints, how can I check if the reference is valid?
  2. To the left of the sequence I’m getting the BP_Player, how do I set it to own the UI? (In the Level BP I’m not getting nor setting a Player and the remove works).

begin overlap has a tendency to fire multiple times. try adding a do once node just after the overlap for debug purposes.

That worked! The BeginOverlap was firing multiple times. I put the Do Once in front of it, then reset it in the end of the EndOverlap flow.