Skip to content

Instantly share code, notes, and snippets.

@ohiofi
Last active April 9, 2018 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohiofi/5c0fdd3a70f6ed7e956a8d5e996fca59 to your computer and use it in GitHub Desktop.
Save ohiofi/5c0fdd3a70f6ed7e956a8d5e996fca59 to your computer and use it in GitHub Desktop.
public bool PlayerIsOnGround(){
bool groundCheck1 = Physics2D.Raycast (new Vector2 (transform.position.x, transform.position.y - height), -Vector2.up, rayCastLengthCheck);
bool groundCheck2 = Physics2D.Raycast (new Vector2 (transform.position.x + (width - 0.2f), transform.position.y - height), -Vector2.up, rayCastLengthCheck);
bool groundCheck3 = Physics2D.Raycast (new Vector2 (transform.position.x - (width - 0.2f), transform.position.y - height), -Vector2.up, rayCastLengthCheck);
if (groundCheck1 || groundCheck2 || groundCheck3)
return true;
else
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment