I’m pretty new to Unreal, and I’m wondering what the best way is to trigger labels for interactable objects. So if a user looks at a door, a label like “E to Open” pops up.
I thought I could do a raycast on the Tick event, but that seems more resource-intensive. I thought about doing a collision enter on the capsule, but you have to get really close to the interactable object, or the interactable object would need a big box collider.
A line trace is the usual way to show “E to Open”, and it stays cheap if it is not a raw Event Tick.
Run it on a timer of about 0.05 to 0.1 seconds. From the camera, Line Trace by Channel on Visibility, or on your own Interact trace channel, out roughly 300 to 500 cm. On a hit, check an Interact interface (Does Implement Interface, then something like Get Prompt Text). If the hit actor changed, update one widget. If the trace misses, hide it.
A capsule overlap only knows the object is nearby, not that the player is looking at it, so the prompt shows up for things beside or behind them. The usual split is a larger sphere overlap for “in range”, then the camera trace to pick the one under the crosshair. Skip the trace entirely when the overlap set is empty.
Keep a single HUD widget and change its text. Spawning a world-space widget on every door costs more and fights occlusion. The interact key itself should be an Enhanced Input action, not another trace: on press, reuse the cached hit (or trace once) and call the interface.