Making raycast ignore First Person Controller?

I’m having troubles creating a little code that lets me interact with objects in real time. In other words, for example if I stand less than 1 meter away from a light switch and aim precisely at it and click then it turns the lights on.

My current issue is that the raycast is interfering with the First Person Controller’s collider when I aim too low. I tried layermasking with the following code:

var layerMask : int = 0 << 8;
if (Physics.Raycast (transform.position, transform.forward, hit, 1, layerMask) && Time.time > nextClick) {

The number 8 is supposed to be the eigth layer I applied to my First Person Controller, but it aint working.

I’m also a little skeptical about the whole system of using raycasts and my main camera to interact with objects, is there a better solution for this?

You can make the raycast longer so you can use the switch from further away, but it still won’t solve the issue with needing to point directly at the switch to use it.

A non-raycast way to do this is to create another object to act as a trigger for the switch, or even the collider that is attached to the light switch. Just make sure it’s a trigger and that it’s bigger than the switch so the player can stand inside. Then you can code it so that when the player is in the trigger, they can use the switch. The only problem is that they can still use the switch if they are facing the wrong direction as long as the player is in the trigger.