I have read all the threads on layerMasks I can find, as well as the thread on UnityAnswers, and I am still completely confused.
Here is the set up.
I have a disc that I want to raycast against, and nothing else. In my scene, the disc can be obscured by other objects with colliders. I want to cast a ray that ignores everything except the disc.
The disc is assigned to a layer called “Disc”, which in the Tag Manager is User Layer 10.
Now, I create a bitmask for the layer like so:
private var lm : int;
lm = 1 << 10;
First question, is that correct? Being that layers are a 0 based index, am I looking for 1 << 10, or 1 << 9?
Next, I use the layerMask thusly:
if (Physics.Raycast (ui_ray, ui_Arrow_hit, 1000.0, lm))
Now for clarity, everything about the code works perfectly, if I remove the layerMask.
The question is, does everything look correct for what I want to do? Cast a ray that only hits the object assigned to the “Disc” layer (User Layer 10).
I have also tried creating a public variable to set in the inspector for the layermask, but it still doesn’t work correctly.
I am so confused.