Detect if raycast no longerhits actor

Hi,

In my game i have fences that can be repaired. When a fence is destroyed, the user is able to hover over it with his cursor and then a transparant green version of the fence should appear indicating that you are selecting it for repairs.

N ow the issue is that im shooting a raycast from my player controller via “hit results under cursor by channel”. The hit detection works fine as intended. But i’m struggling to find a way to detect if the raycast is no longer hitting the object so that the green fence can disappear again. Right now the green fence appears and stays visible forever. I want it to disappear as soon as the mouse is no longer hovering over it. But for the love of God i have tried every possible method i could think, down to rediculous stacks of nodes to make it work, but i can’t seem to get around it.

Does anyone have any suggestion what so ever on how to achieve this? It’s one of the main features of my game, so i can’t just drop it sadly. :frowning:

Could you post your current setup so we can see how you’ve got things laid out?

I assume you’re running the cast every time the mouse moves? The first time it hits the fence actor (I’ll call it Fence_BP), store Fence_BP as a variable, and call an event to spawn the green fence. When you move the cursor away the cast will fail, and you can use the Fence_BP variable you saved earlier to call an event to disable/destroy the green fence. Does that help?

Hey!

I think you are forgetting to reset the fence pointer to nullptr!

Try to set the actor to the hit actor even when the hit result is false.

Hope this helps! :slight_smile:

Elias