touchingGround()

Found in:

private bool touchingGround(){
      RaycastHit2D raycastHit;
      Vector3 characterScale = transform.localScale;
                                        //start ray                      //direction          //length                     //check against this layer
        raycastHit = Physics2D.Raycast(polygonCollider2D.bounds.center, Vector2.down, polygonCollider2D.bounds.extents.x, groundLayerMask);
      Color rayColor;

      if(raycastHit.collider != null){
        rayColor = Color.yellow;
      }else{
        rayColor = Color.red;
      }

      //draw ray on screen when Gizmos enabled
      if(characterScale.x > 0){
        Debug.DrawRay(polygonCollider2D.bounds.center, Vector2.down * (polygonCollider2D.bounds.extents.x), rayColor);
      }
      return raycastHit.collider != null;

    }


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *