Raycast : ignore layer

Is there a way to make a Raycast ignore a particular object’s collider (aside from placing that object in the Ignore Raycast layer)?

I’m familiar with using a layer mask to Raycast only on a single layer, but can I do the opposite - use a layer mask to make Raycast ignore a single layer?

You can make raycasts use whatever layers. Have a public variable:

var layerMask : LayerMask;

and use that in the raycast.

–Eric

Here’s what I normally do:

private var Layermask = 1 << 9;

function Update () {

if (Physics.Raycast (ray, Hit, 100, Layermask))

{do stuff here};

}

That will raycast on layer 8… But say I need to ignore layer 8…

Now, I’ve just found what I need in the Unity Manual…