User Layer that Ignores Raycast?

I’ve found numerous answers on this, but I’m still lost on to where to put any of that code. (as in what script)

Basically I’m looking for something that will make certain layers ignore the mouse click. (And other Mouse Events) Ignore Raycast Layer works perfectly, however i need multiple layers that ignore raycast.

I’m confused as to what script I would need to edit/make, in order to achieve this, and on what GameObject to place this script, or if it matters.

Thank you.

So when you do your raycast you pass in a layer mask as a parameter to the Physics.Raycast method.

When you create the layer mask, and you want to ignore multiple layers you declare its something like this : -

var layerMask = ~(1 << 8 | 1 << 9);

That would ignore layer 8 and 9.

You can see the layer numbers by clicking layers in the top right a and picking edit layers.

Hi, you can do this…

[SerializeField] private LayerMask inputLayerMask;
       
private void Start()
{
	Camera.main.eventMask = inputLayerMask;
}

Then in the game object’s inspector set what layer mask, or masks, you want to receive mouse input.