Skip to content

Instantly share code, notes, and snippets.

@ohiofi
Last active April 12, 2018 17:17
Show Gist options
  • Save ohiofi/d4fbd27bdb90178c0ca11ecb749278ac to your computer and use it in GitHub Desktop.
Save ohiofi/d4fbd27bdb90178c0ca11ecb749278ac to your computer and use it in GitHub Desktop.
public int GetWallDirection(){
bool isWallLeft = Physics2D.Raycast (new Vector2 (transform.position.x - width, transform.position.y), -Vector2.right, rayCastLengthCheck);
bool isWallRight = Physics2D.Raycast (new Vector2 (transform.position.x + width, transform.position.y), Vector2.right, rayCastLengthCheck);
if (isWallLeft)
return -1;
else if(isWallRight)
return 1;
else
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment