The game needs to know if the player is colliding or not but it only detects if it is colliding but not if its not so how do that someone told me to use OnCollisionExit but it wont work 
void OnCollisionEnter(Collision col)
{
Debug.Log("On the ground");
}
void OnCollisionExit(Collision col)
{
Debug.Log("On the ground");
}
}
OnCollisionEnter and OnCollisionExit require that the GameObject you attached this script to have a Collider. Did you make sure to add one.
Also, these functions are “oneshots”, in the sense that they will be called once when the event occurs but afterwards the collision state is lost if you didn’t save it anywhere.
Personally, I like to use a counter to keep track of all Enter/Exit events to make sure that my object is not colliding with anything in case it would hit more than one other objet simultaneously or if multiple Enter events occur one after the other for multiple objects overlap without getting the Exit events of the first ones hit yet.
You could try this:
pulic class SomeScript
{
private int collisionCount = 0;
public bool IsNotColliding
{
get { return collisionCount == 0; }
}
void OnCollisionEnter(Collision col)
{
collisionCount++;
}
void OnCollisionExit(Collision col)
{
collisionCount--;
}
}
I have a similar problem. However, the proposed solutions does not work. I destroy the colliding object after collision so the onCollisionExit is never called. The collisionCount never counts down.
Any ideas?