Make object kinematic when grounded?

Hello, I am fairly new to Scripting/Game making. I have been trying to figure out how to make my objects kinematic ONLY when it is on the ground or on top of another object. If anyone knows how to do so all help is very appreciated. Note: This is a 2D game.

public LayerMask ground; // assign in the inspector, the layers that you want to check as “ground” or “top object”

        bool  isGrounded; // this will go true when gorunded, flase when not.

    float radius; // this is the radius of the circle collider that you will assign to the gameobject in question, put in the botton or where you want to check the collision.

    Transform checkGround; // this is the transform of the child you will assign to the main object, you will add a circlecolllider2d component to it, and assing the radius that you think properly to check the collision.
    void Start()

    checkGround = gameObject.Find("check").GetComponent<Transform>();
    radius = gameObject.Find("checkGround1").GetComponent<CircleCollider2D> ().radius;
    void FixedUpdate()
    isGrounded = Physics2D.OverlapCircle (checkGround.position,radius,ground);

 gameobject.rigidbody2D.isKinematic = true;