- Home /
Why do I need bitwise shift operator in linecast?
In the sample 2D project with 4.3, there is this line:
grounded = Physics2D.Linecast(transform.position, groundCheck.position, 1 << LayerMask.NameToLayer("Ground"));
I understand all of this and implemented something similar in my own project. But I don't understand why I need the '1 <<' bit when using the LayerMask.NameToLayer function.
If I don't include it in my project then it doesn't work of course, but why not? I've looked up what the '<<' means and it still makes no sense to me.
Can someone quickly explain what I've missed please? Cheers.
Thanks Alucard. If you create an actual answer with the text of your comment, I'll choose it so that this question is considered answered.
Answer by AlucardJay · Mar 19, 2014 at 08:21 PM
Bunny83 did an excellent answer for this, but I cannot find it. Here's another that may be useful : http://answers.unity3d.com/questions/8715/how-do-i-use-layermasks.html
Also read the Documentation, scroll down to Casting Rays Selectively
Your answer
![](https://koobas.hobune.stream/wayback/20220613140656im_/https://answers.unity.com/themes/thub/images/avi.jpg)