Confusion with collision detection

I’m having a little trouble understanding how the collision detection works. Why is it that I have to put isFalling = true; Since the object is not touching anything why would it just ignore that information unless I put isFalling = true;

 if(Input.GetKeyDown(KeyCode.W) && isFalling == false) 
 {                                                      
    rigidbody.velocity.y = jumpHeight;                                
 }
    isFalling = true; 

function OnCollisionStay ()
{
  isFalling = false;                                    
}

I’m going to try and answer my own question. I’m assuming that from the start that the script is “Assuming” that the object is always in space. So it checks to see if the conditions are met and if the object is indeed on the ground then it executes the code. If you push the button again while its in the air, then it will not do anything because the condition was not met. It just goes back to its default value from the beginning that the ball was floating in space. Sry if this question seemed somewhat unreasonable. It’s just that it didn’t click.

private var onGround = false; 

if(Input.GetKeyDown(KeyCode.W) && OnGround == True)
{
rigidbody.velocity.y = jumpHeight;
}
 
function OnCollisionStay ()
{
onGround = true;
}