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.