The ground must falls after 5 seconds

When I pass on to a ground with the Character player , the ground must falls after 5 seconds
but this script created by me does not work how can I fix it?


using UnityEngine;
using System.Collections;

public class Groundfall : MonoBehaviour
{

    [SerializeField] private Rigidbody m_ObjectToFall;

    void Start()
    {
        m_ObjectToFall.isKinematic = true;
        m_ObjectToFall.useGravity = false;
    }
    void OnTriggerEnter()
    {
        StartCoroutine(Fall());
    }

    private IEnumerator Fall()
    {
        yield return new WaitForSeconds(5f);
        m_ObjectToFall.isKinematic = false;
        m_ObjectToFall.useGravity = true;
    }
}

Why are you using SerializeField? Just make the variable public. Are you sure that your ground has “Is Trigger” set. What you might want to use is void OnCollisionEnter(Collision hit) and check the tag of Collision hit using - hit.gameobject.tag to see if it was the ground you hit with. If you want you could also change the transform.position.y and make it decrease at a steady rate to give it the impression of falling. In fact this would probably be the best way to accomplish this but it really depends on your scene. If changing the transform doesn’t work for you the best way to accomplish your goal would be this:

    void OnCollisionEnter(Collision hit)
    {
        if (hit.gameObject.tag == "Ground")
            Invoke("Fall", 5.0f);
    }
    void Fall()
    {
        ground.isKinematic = false;
    }