# How to create a widget when aiming at an actor (line trace) and then close it when not aiming at it ?

**URL:** <https://forums.unrealengine.com/t/how-to-create-a-widget-when-aiming-at-an-actor-line-trace-and-then-close-it-when-not-aiming-at-it/1673158>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [February 7, 2024, 10:13pm UTC](https://forums.unrealengine.com/t/how-to-create-a-widget-when-aiming-at-an-actor-line-trace-and-then-close-it-when-not-aiming-at-it/1673158 "2024-02-07T22:13:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 8, 2024, 7:31am UTC](https://forums.unrealengine.com/t/how-to-create-a-widget-when-aiming-at-an-actor-line-trace-and-then-close-it-when-not-aiming-at-it/1673158/4 "2024-02-08T07:31:57Z")

</div>

Example:

> [@Third person crosshair object highlight troubles](https://forums.unrealengine.com/t/third-person-crosshair-object-highlight-troubles/252041/13):
>
> The communication in the example revolves around Inheritance + Interface - a potent combo, imho. the base class implements the interface (which children inherit) the widget uses the same interface - calls children receive can be propagated: Actor → Widget Component → Widget without casting or finding user widgets (this can be done in many ways, though) the player has a collision sphere and sends an interface call to overlapped actors as we approach: [image] [image] Above, handl…

A more recent one:

> [@Moving an object by pointing another object at it](https://forums.unrealengine.com/t/moving-an-object-by-pointing-another-object-at-it/1657869/2):
>
> See if this point_down helps with this point_up_2 particular bit. a standard forward camera trace: You’d use an interface or inheritance if there are more types to handle, ofc. not sure how you want stuff to move, here it’s via a timeline: which results in: the branches in the script prevent it from spamming since we’re tracing on Tick: Hopefully you can adapt it to your needs. It’s a setup similar to this one:

* * *

Essentially, store a ref to what you hit last, and base the logic on whether it’s valid.

Oh, the Fairy. I remember her.

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-create-a-widget-when-aiming-at-an-actor-line-trace-and-then-close-it-when-not-aiming-at-it/1673158)._
