Character Controller blocking mouse clicks

I have my FPS camera positioned behind the character controller as seen in the image below. My issue is that when the player tries to click that lever on the wall, the character controller is blocking the mouse clicks. I can solve this by making the character controller really short, but that’s far from ideal. How can I make the Character Controller either ignore mouse clicks or at least propagate them instead of consuming them?

Probably best to Raycast from where the click is (the Camera class can give you the ray from any arbitrary screen position) and then use Layers and LayerMasks to specify you are only interested in hitting things that you want hit.

Cool, I’ll give that a try, thanks @Kurt-Dekker

Just in case anyone else stumbles on this with the same question, here’s the solution I used based on @Kurt-Dekker 's idea. I placed a thin cube covering the whole front of the first person camera to catch all clicks in that area. When it was clicked, it called this function below. I placed the only objects I cared about being clicked on a layer I created called “DungeonInteractable”.

public void ClickedDungeonArea()
    {
        RaycastHit hit;
        Ray ray = cam.ScreenPointToRay(Input.mousePosition);
        int layerMask = 1 << LayerMask.NameToLayer("DungeonInteractable");

        if (Physics.Raycast(ray, out hit, 3f, layerMask)) {
            Transform objectHit = hit.transform;

            print(objectHit.name + ":" + objectHit.gameObject.layer);
        }
    }
1 Like

Excellent! This seems like a perfectly satisfactory solution. Glad to hear it worked out.

1 Like