Jumping Problem

I am creating an endless runner game and made a character with some basic movement. One thing I noticed, however, was that my character was able to jump, even after walking off of a platform.
I have already created a “grounded” boolean and have set it to false, and done:

    if (Coll.gameObject.tag == "Ground")

    {

           grounded = true;

    }  

The platforms I have created are tagged as “Ground”.
I also have it so that grounded is set to false when I press Space, the jump button, so he cannot jump multiple times in midair.

So grounded is set to true when my character is touching the platform, but when I make him walk off, “grounded” is still checked as true and my character is able to jump one last time. Is there a way to make the object detect that it is no longer touching a tagged object?
It seems like such a simple thing to fix, but I cannot seem to find the solution.
Thanks in advance.

The easiest way to fix this is to add a small collider at the feet of the controller, and in its collission you should set grounded to true, and when it’s not colliding set it to false.

For this you can use MonoBehaviour.OnCollisionStay and MonoBehaviour.OnCollisionExit
Best is to use the collider as a trigger maybe.
Then you will have to use MonoBehaviour.OnTriggerStay and MonoBehaviour.OnTriggerExit respectively.