Repeating function OnCollision

I want to stop reapeating function OnCollision in my script. I have planet whose radius is decreasing when Player is on the surface this planet. Player have Rigidbody and it stays on the surface.
It looks like:

Is there any way to prevent continuously calling function OnCollision (Enter and Exit)? I want to have only one call.

The problem is not the function. The problem is you keep removing the floor from underneath your player and the player keeps falling onto it. Kinda of a physical problem. Solution? Maybe disable physics for all players on the currently shrinking planet and move them 100% synchronously down by script together with the surface. When shrinking is done, re-enable physics. This is somewhat a known trick in games, when control over a body is passed from physics to animation/script and back. I’m not sure how you would have both at the same time though. Because on a technical level you’re trying to combine continuous physics with descrete instant collider shrinkages. This is generally not recommended, even by the Unity documentation (changing position of a rigid body rather than applying forces for example), because it produces incontinueities.

You could create (or enable) a joint between the player and the planet on the first Enter callback until he lifts off the surface again. This way, you are using the physics system itself to enforce your gameplay constraints.

Or, you could remember the last collider your player was bumped into and ignore all future OnCollisionEnter with this collider (as they have to be “false triggers”.) If you have any event that makes you really leave the surface, you can reset the variable there.

For example:

Collider lastBumpedInto;
void OnCollisionEnter(Collider other)
{
    if (lastBumpedInto == other)
        return; // false trigger just because we shrank the collider..
    lastBumpedInto = other;
    
    ... // your normal stuff
}

...

// somewhere when you decide to lift off the collider, e.g.
// because user pressed "Jump" key..
if (Input.GetButtonDown("Jump"))
{
    lastBumpedInto = null;
}