How do i remove a widget from view port using trigger boxes

I’m trying to have it so when to move into a area it shows the controls on how to play and when you move out of the area you don’t see the widget anymore but when i try to remove from parent when OnActorEndOverlap. If you guys and gals could help i would really appreciate it.

1 Like

Hello,

What you can do is:

Create a blueprint that creates your widget and adds it to the viewport. I created an actor blueprint called SpawnThatWidget that contained a Box Collision component, which I used as my trigger.

In the blueprint, on Begin Play, I created the widget, and added it to the viewport. After which, I promoted the Return Value of the Create Widget pin to a variable so I can use it to remove the widget in my First Person Character blueprint, which you’ll see here in a minute.

After I set up my Spawn That Widget blueprint, I went into the First Person Character and added the blueprint below:

This allowed me to cast my overlap to my SpawnThatWidget blueprint, and if it succeeds, it will remove that widget from the viewport using the Remove From Parent node.

Finally, I placed an instance of Spawn That Widget in the level, and then hit PIE. After doing this, and walking into the Box Collision that was added to the Spawn That Widget blueprint, my Test Widget disappeared as expected.

Let me know if you have any additional questions regarding this setup.

Have a great day

1 Like

I searched for the node that says ( • Target WidgetVariable • ) but i couldn’t find it

1 Like

You wont find it. Search instead for WidgetVariable and use the Get WidgetVariable.

I want my trigger box to add it to view port when you enter it but i also want it to remove from parent when you leave the trigger box.

Then what you’ll need to do is on Event Actor Begin Overlap, create the widget

Then on Event Actor End Overlap, remove the widget from the parent.