I’m trying to create a widget that pops up whenever you’re in a certain area looking at the door. I want it to be a widget so that it appears on the players screen like it does on many games like borderlands or fallout with the little text pop ups for interacting with objects. I’ve got it working inside of a trigger box but it’s always visible, not just when you look at the door. Anyone know how to do this?
How would I make a widget pop up whever I'm looking at a door?
Lot’s of ways to approach this. What I’d start off trying is the following outline:
- OnActorOverlap of the trigger volume, add a Unique Array entry for the character in to an array and set a boolean variable to true.
- In the Tick Event for the door (this assumes the trigger is a child component of the door); if the variable above is true, then loop through the array of actors and use the DOT product to determine if each actor is looking at the door within an acceptable amount of rotation (for example, a DOT product value of 0.7071 would accommodate -45.0 to 45.0 deg of “within view”). For those within the desired viewing range (use a branch/True); ensure that the widget is displayed as you like for the character. Mind you, this will happen with every tick, so put in some form of sanity check to only enable the visibility once.
- As each character leaves your overlap, remove them from the array and check the array for the number of entries (it’s LENGTH), if the length of the array is <= 0, then turn off the boolean variable from step 1 so you’re not wasting logic cycles every tick.
Hey, thank you for the help but is there any way you could show me an example of how it would work with a collision box on the door because the trigger box is not a child actor of the door right now. I’m also pretty new to blueprints so it’s a bit confusing.
I don’t mind putting something together for you, but I am involved in other projects, so bear with me
Here we have a mockup Door Blueprint with a box collision component added, resized and named as your trigger, notice the collision settings
Here we have the Begin/End Overlap events for the collision (trigger) volume
You may want to expand upon the End Overlap to remove the Widget from view on the character in the event they leave the volume without doing interaction that would otherwise of removed it.
Here is the Tick event for the door, notice the value of the DOT product, this would accomodate a viewing angle of up to 33deg left or right.
And lastly, a quick generic mockup of a function within your character for displaying the widget. You can greatly expand upon the logic of this, such as passing an enum for the desired object/widget type that you “switch” off of, so you’re not creating a bunch of unique functions for each interaction… Don’t forget to properly set the visibility boolean as you display/remove the widget.
This should get you pointed in the right direction to come up with a solution that works for your project.
This was drafted for client only setup.