How to tell object that I am not aiming at it anymore

Hello, by LineTracing from my camera I can tell object to do some event.
For example, when I look at BP_UseableItem I make CastToBP_UsableItem and call event for making an outlane (or whatever)

And when Im not looking at this object anymore how can I tell him to stop being outlined (for example) since I cant Cast to it anymore?

Whats the efficient way?

The easiest way would most likely be to simply do a linetrace every tick and every time it hits something set that something to have an outline that fades over a small amount of time. This will reset it as long as you are aiming at it, but it will go away shortly after you aim away.

You can also have a check inside the actor doing the linetrace to see if we are still hitting the same object. Once we are not you can call a function in the other actor to toggle its outline. This way you will toggle it when you start hitting it and you will toggle it when you stop hitting it.

you can do this using vector math instead of linetrace too.
you have an exemple of this in the substance plugin demo scene (on the market).
this work using a vector math, and it returns 1 when you r looking to the objects pivot point. so you can add a “tolerance” for it.
here an exemple :
the upper part is for distance, the bottom one for the “look at”

@NoobsDeSroobs Thanks, Ive come with idea of making check for hitting same or new actor every tick on myself but thought there should be more efficient way with something like OnStopBeingLookedAt event :smiley:

@expose Ye, I saw it but making this kinda math on every usable object in world every tick looks kinda heavy.

Thanks guys, I guess I’ll have to store hitting Actor and check for it every tick until I find better solution.