Solved: How to know if an object collides with anything at all? (Jumping issue)

This is a pretty simple jumping script,

    void onUpdate() {
            if (Input.GetButtonDown("Jump") && onGround)
                    rigidbody.velocity += new Vector3(0, jumpVelocity/50, 0);
    }
    
    void OnCollisionStay(Collision collision) {
    	foreach (ContactPoint contact in collision.contacts)
    	if (Vector3.Angle(contact.normal, Vector3.up) < maxSlope)
    		onGround = true;
    }
    	
    void OnCollisionExit (Collision collision) {
    	onGround = false;
    }

but you see the problem is that when the object (let’s say floor) gets destroyed and there are no other colliders, OnCollisionExit is not triggered and OnCollisionStay also stops functioning. In which case my player can still jump infinitely many times until I hit a floor.

I wonder if there is maybe a way to know if a player does or does not collide with anything at all. That would solve my problem.

But here’s my code to check if you’re on the ground or not, and it works:

void OnCollisionEnter(Collision hit){
	if (hit.gameObject.tag=="terrain"){
		grounded=true;
	}
}
void OnCollisionExit(Collision hit){
	if (hit.gameObject.tag=="terrain"){
		grounded=false;
	}
}

Hope this helped - Hyperion