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.
Answer by Gmotagi · Nov 24, 2016 at 11:25 PM
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.
See, I understand that much, and I apologize if this is a noob question, but I can't figure out what script (or what game object), I need to add this code to, for it to affect the mouse.
Answer by SpiderJones · Mar 27, 2021 at 01:20 AM
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.