Change Cursor Color When looking at Interactable Item

I have code that works as intended. When I hover over an item the Hud Crosshair changes color and when I look away it goes back to its original color.

I want to try and improve the efficiency of this script. I’m coming from Unity and having something happen (especially raycasts) every tick is bad practice if it can be avoided.

I feel like this could be simplified I’m probably missing something very obvious I’m new to Blueprints. Any ideas how to improve this?

This is my function it’s being called every tick in my character blueprint.

Change Crosshair Colour posted by anonymous | blueprintUE | PasteBin For Unreal Engine

first step is use a timer on say 0.1s loop thats already much more efficient

second cache the last hit actor and only update if HitActor != LastHitActor

other options is to see if the camera has moved but this can be tricking since something could move under the cursor.

all that said though something like this isnt super expensive

2 Likes

Thanks for the help. Much better.

Here is the Function:

This is how I call it in event graph from ‘Event Begin Play’:

1 Like