ScriptReference/Physics.GetIgnoreLayerCollision #203
Replies: 1 comment
-
|
If you would like to drive raycasts with the same layer mask as defined in the collision matrix you can calculate the layer mask by using GetIgnoreLayerCollision(), for example: public static int GetLayerMask(int sourceLayer)
{
int layerMask = 0;
for (int otherLayer = 0; otherLayer < 32; otherLayer++)
{
if (Physics.GetIgnoreLayerCollision(sourceLayer, otherLayer) == false)
{
layerMask |= 1 << otherLayer;
}
}
return layerMask;
}
int layerMask = GetLayerMask(gameObject.layer); // Usage example |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
ScriptReference/Physics.GetIgnoreLayerCollision
https://docs.unity3d.com/ScriptReference/Physics.GetIgnoreLayerCollision.html
Beta Was this translation helpful? Give feedback.
All reactions