I was looking at a script i found online and this script has to do with the collision of the character but there is a part I dont understand. More specifically I cant figure out how the value of this variable is calculated
public class Collision : MonoBehaviour
{
[Header("Layers")]
public LayerMask groundLayer;
[Space]
public bool onGround;
public bool onWall;
public bool onRightWall;
public bool onLeftWall;
public int wallSide;
[Space]
[Header("Collision")]
public float collisionRadius = 0.25f;
public Vector2 bottomOffset, rightOffset, leftOffset;
private Color debugCollisionColor = Color.red;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
onGround = Physics2D.OverlapCircle((Vector2)transform.position + bottomOffset, collisionRadius, groundLayer);
onWall = Physics2D.OverlapCircle((Vector2)transform.position + rightOffset, collisionRadius, groundLayer)
|| Physics2D.OverlapCircle((Vector2)transform.position + leftOffset, collisionRadius, groundLayer);
onRightWall = Physics2D.OverlapCircle((Vector2)transform.position + rightOffset, collisionRadius, groundLayer);
onLeftWall = Physics2D.OverlapCircle((Vector2)transform.position + leftOffset, collisionRadius, groundLayer);
wallSide = onRightWall ? -1 : 1;
}
}
Can somebody please explain what the “public LayerMask groundLayer;” does in this script?