Reputation: 302
Below is the Code I read somewhere to keep a check on whether the player is on the Ground or Not.
We have to set the LayerMask whatIsGround
from the Inspector.
I know the OverlapCircle
method creates some kind of Circle but i don't know what exactly doest it do and what does it check.
How does it use the LayerMask
to determine whether it's on ground or not.
public LayerMask whatIsground;
public Transform groundCheck;
public float groundCheckRadius;
public bool isGrounded;
isGrounded = Physics2D.OverlapCircle(groundCheck.position,groundCheckRaadius,whatIsground);
Upvotes: 1
Views: 2759