unity how to use layermask and compare with collision layer code example
Example 1: Check object is in layermask unity
public bool IsInLayerMask(GameObject obj, LayerMask layerMask)
{
return ((layerMask.value & (1 << obj.layer)) > 0);
}
Example 2: collider layer = to layermask unity
layermask == (layermask | (1 << layer))