How to end highlight effect using LineTrace

Looks like you need to reference highlighted actor and compare it in next trace with new hit actor.

if its the same actors, there is no need to do anything.

if its different, you need to disable custom render depth for old one, reference new one and enable custom depth for it.

Hi there. I’ve been following various tutorials on how to highlight objects using LineTraceByChannel. I have managed to get it working so when I Play the file, I look at a specific mesh and it highlights. As you can see from the screenshot the black line appears when I look at the object but remains when I look away.

I have tried a few things, such as adding another blueprint interface with the opposite effect on false result of the branch, but other than this I am at a loss.

As I am fairly new to blueprint I don’t really know where to go from here, any help would be appreciated.

The blueprint for the linetrace in the character controller

The event called from the end of the previous blueprint

Do a new variable (name as for example saved actor) in your code (actor reference), save/set hit actor from line trace to this variable after you set render custom depth!

Now after linetrace if linetrace bool return is false check saved actor is valid, if valid call set custom depth false and invalidate saved actor reference (just do a set node which will set to null)

If linetrace was true check saved actor is equal with hit actor, if not call set custom depth false on saved actor then call cutom depth true on hit actor, after saved actor = hit actor. If hit actor and save actor are equal, you do not have job :wink:

And you covered when player is looked at other mesh :slight_smile:

short explanation: if you save actor reference at end of tick or of your function, in next tick you can check if player seeing that object or not… if not you have reference and you can disable custom depth render!

This worked great, thanks!