I’m trying to make an aim snapping. When the player is looking at an interactable object (like a door or a light switch), the aim cross snap the object. If he is looking anything else, the aim cross moves to 5 meters in front of the player vision.
The code behind my game just sweeps a sphere, and if it detects an interactive object and if that interactive object is being rendered on the screen, it sets a variable called LookingActor to the interactable object that the player is looking.
As you can see in the video bellow, The aim cross snaps to the door and to the light switch. If the sweeped sphere gets the light switch behind the wall, the aim cross doesn’t snap, so it’s ok, but if the sweeped sphere gets a light switch behind the window (or any other translucent material) the aim cross snaps to it, and I don’t want this to happen.
Do someone have an idea about how can I solve this problem or know another way to make this system?