So i saw a few tutorials and wrote a similar code but i cant get the raycast to work for me. I need the raycast to see if my char is grounded to enable the jump. Here is the program:
private bool isGrounded()
{
float extraHeightText = .01f;
RaycastHit2D raycastHit = Physics2D.Raycast(GetComponent<Collider2D>().bounds.center, Vector2.down, GetComponent<Collider2D>().bounds.extents.y + extraHeightText);
Color rayColor;
if (raycastHit.collider != null)
{
rayColor = Color.green;
}
else
{
rayColor = Color.red;
}
Debug.DrawRay(GetComponent<Collider2D>().bounds.center, Vector2.down * (GetComponent<Collider2D>().bounds.extents.y + extraHeightText));
return raycastHit.collider != null;
}

