Try using the while loop. You can use collision to set a bool saying whether you are on the ground or not.