I have a character that is interactable with the player, the character has a box collision with it. when the player enters the box and presses E, the widget should go away and a new one should open up. Also when the player leaves the box the E to interact widget should disappear. how would I do this?
What do you have so far?
Just the Widget and a character with a box colision
First, be sure you’ve set your widgets to variables so they’re easy to remove when necessary. But once you’ve got access to them, simply use a Remove From Parent node.
**And the long winded explanation: **
When the character is overlapped, you’ll need a “Begin Overlap” trigger on your OTHER character to check for the player. This needs to use a Cast To node to cast to your player actor to verify that the right actor has overlapped and it’s not another NPC or a tree or something. Once you’ve cast, then you have access to your player character as a reference. You can drag this out and access any of his variables and modify them now as you see fit. I’d recommend setting the player character to a variable here for access later on in case these two will be interacting again in the future.
Now with the player reference you can just grab a reference to your first widget, use the Remove From Parent node, then create a new widget right after that and set it to another variable for disposal when you trigger the “End Overlap” event. This you’ll also want to cast to your player character again, or use a branch to check if the overlapped actor is the same as the player who just entered otherwise a cat walking by could end the conversation or whatever for you when you don’t want it to.
I attached a quick blueprint I threw together using my own project. MyPauseMenu and MyHUD are both widgets. They’re both variables I have setup on MyCharacter which is my main player controller. I didn’t add an end overlap event, but it works just like the begin version.
If this didn’t help, let me know.
EDIT: I totally missed your “E” control. Though most of this should work the same, you can simply remove the Interact Popup Widget when E is pressed on the player character. Use an isValid? node (the one with the ? at the end) to check if the Interact Popup Widget already exists or not when E is pressed. If so, remove it.
The Press E is the Widget just to let you know
Also what you had doesn’t work for me, when the player is in the box, the widget shows, when he leaves it disappears.