Raycast2D not working

I’m making a platformer and trying to restrain the character jumps. I decided to make it so that whenever the raycast doesn’t detect something you can’t jump.

I decided to make the raycast code and make it write whatever it is hitting in the debug log. However, even though my raycastOrigin is floating in space (with a square very far below it) the debug log still says “square”.

RaycastHit2D hit = Physics2D.Raycast(raycastOrigin.position, Vector2.down);

Debug.DrawRay(raycastOrigin.position, Vector2.down, Color.green);

You may need to add a distance to the Physics2D.Raycast. Something like Physics2D.Raycast(raycastOrigin.position, Vector2.Down, 10f). If you don’t add a distance by default I think it may be infinite so any square beneath them will be detected. You can change the drawn ray to this by changing Vector2.down to the hit variable. Hope this helps!