Why is this raycast working?

I’m following a tutorial for making a rigidbody character controller and it suggests the following method to test whether the capsule collider is grounded:

Physics.Raycast(transform.position, -transform.up, capsuleCollider.height / 2 + 2);

My capsule collider has height 1.8 (around the height in meters of a typical human). That method call is passing half of the capsule height (presumably 0.9) plus a whole 2 for safety! So presumably we should be able to jump when we are around 2 meters of the ground. But, bizarrely, it works. Repeatedly hitting the jump button, it does not jump again until it touches the ground again. If I increase it to, say, 20, then it finally manages to jump mid air. What’s up with this?

This works, because the third value (capsuleCollider.height / 2 + 2) describes only the length of the ray that is shot, not how far away your collider is. So it won’t hit something that is farer away then 2.9 in your case, but everything in a shorter distance.

My bad, it actually was allowing me to jump when I got to within 2 meters of the ground. It’s just that for some reason those 2 meters really didn’t look like 2 meters.