private bool NeighbourHasWallInDirection(Vector2 neighbourDirection, int directionId) { RaycastHit2D hit = Physics2D.Raycast(this.gameObject.transform.position, neighbourDirection, 1f, LayerMask.GetMask("Wall")); if (hit) { SpriteSelector selector = hit.collider.gameObject.GetComponent <SpriteSelector>(); if (selector) { return(selector.HasWallInDirection(directionId)); } } return(false); }