Raycast from camera only working from certain angles

So with a first person character I’m using raycasts to check for interactions of the player. I first made doors, which work fine. Then I made a key on the ground which didn’t seem to work properly. Then a cupboard with two doors and two drawers, each with a collider to open separately. All except for the door are working really weirdly. Even thpugh the raycast is hitting it, it says nothing is being hit :frowning:

The first two images show an angle where the camera doesn’t detect the object to interact for some reason (bigger crosshair means you can interact). The next two show an angle where it detects the object. ???

It looks like you don’t have any LayerMask set for the raycast. This means that at certain angles the raycast is colliding with the collider of the FPS character and blocking it.

You should set a public LayerMask variable and set your desired interaction layers there, but don’t forget to add the relevant objects to those layers.