Unity LayerMask
Tick layers and get the bitmask for Physics.Raycast plus a line of C#.
- Category
- SCP:SL, Steam and Unity
- Price
- free
The tool starts in your browser.
Everything is calculated in your browser. Nothing you type is sent to our server.
How to use it in three steps
The tool as a schematic with this page's example. Each step's number stands where you take it: in the fields, at the result or outside the tool.
Tick the layers the raycast should see.
Read the mask number.
Copy the C# line with the LayerMask.
Six sets of layers and their mask
Physics.Raycast takes a mask, not a layer number: layer n is 1 << n. Layer 31 is the sign bit, which is why an int with it comes out negative, and a full mask is -1.
0, 8, 9the example from the tool's description2Ignore Raycast onlyall but 2everything but Ignore Raycast, the Invert button31the last layer is the sign bit0-31all 32 layers-nothing ticked6 of 6 cases as expected
Questions
Related tools
The tool does one job. If the same thing should happen automatically in your bot, server or system, we build it.
Missing a tool you need?
Tell us what you want to calculate or generate. We will tell you whether a tool is enough or an integration in your system fits better.