Raycast upwards

What I want to do is simple. I have a player character that can crouch and I want to make sure he can’t un-crouch when there isn’t sufficient room. So I thought the best solution would be to cast a ray up and check the distance from the character to the ceiling. But for whatever reason I can’t seem to cast a ray upwards. I have tried many different ideas none of which have worked. The ray’s starting point seems fine but it’s end point is always the same no matter where my character is in the scene. Any solution or advice is more than welcome.

Use transform.up instead of Vector3.up.

transform.upis one unit up from the player position.

Vector3.up is (0, 1 ,0)

So your ray goes from position to that point near origin.