How do I know when a line trace no longer hits?

Hi.

I have set up a system where looking at specific objects turns on a highlight over them. The remaining piece I cannot seem to figure out is how do I turn the highlight off when the player is no longer looking at it – i.e. when the line trace does not hit?

This is what the blueprint does now:

Any help appreciated!

Hey kaisellgren-

You can use the Return Value of the line trace node to determine what behavior to take if a hit is / is not registered. If the hit does occur, your current setup would turn the highlight on. I would also add an actor component variable so you can store which Hit Component you’re setting the highlight for. In the case that the hit fails or no longer occurs, you can then use your component variable to set the highlight to off. When you hover over another actor, it will replace the hit component variable so that you are only highlighting the object you are currently looking at.

Cheers

1 Like

Thank you! I got it to work with this: