Creating press "E" to open/close widget for a door,chest,etc...

Hi, I’m trying to write a blueprint where when I was near the door or chest or whatever could be opened or closed I want my screen to say “Press “E” to open” when the door is closed, and when the door is open I want it to say “Press “E” to close” I cant seem to figure it out. Any help would be much appreciated. Thanks!!!

Define two interfaces:

IInteractable:
GetPossibleInteractions() -> Array(Name, Enabled)
PerformInteraction(Name)
IInteractor:
AddInteractable(IInteractable, FocusPos)
RemoveInteractable(IInteractable)

Implement the IInteractor interface in your player Pawn.

Add an overlapping sphere in front of your door/chest/casket. In On Begin Overlap, query the overlapping actor for the IInteractable interface, and call AddInteractable() on it. In On End Overlap, call RemoveInteractable()

Inside the Pawn, keep a Set<IInteractable> and add to it in the add function, and remove from it in the remove function.

In your UI, iterate of the set of interactables, and show each possible interaction from each possible interactable. Or just pick the first one, or the one whose FocusPos is closest to the center of the screen, or somesuch.

When the user chooses an available interaction, call PerformInteraction() on the IInteractable.
You can doll this pattern up with special highlight states, menu interactions, and so on – but the basic pattern is quite solid, and should be easy to get going. If you’re a networked game, you’ll want the overlap/Interactable test to happen client side but the actual PerformInteraction() to be verified and executed server side.