if (controller.isGrounded == false) (for more than) public int time = 1.0F; // do stuff

Hello Unity community :wink: your looking nice today.

Soooo for the question:
How would I detect if a player isn’t grounded for more than a specific time? E.G.

    void Jump()
    {
        if (controller.isGrounded == false &&  has been false > than time)
        {
//stuff            
        }

Thanks in advance!!

public float timeSinceLeftGround;
public float timer;

void Start()
{
    timer = 2f; // timer lasts for 2 seconds
}

void Jump()
{
    if (!isGrunded && Time.time - timeSInceLeftGround > timer)
    {
        //do stuff
    }
}

void Update()
{
    if(!isGrounded)
    {
        timeSinceLeftGround += time.deltaTime;
    }
}

// add this wherever isGrounded is set to false
timeSinceLeftGround = 0f;

I solved it with the following

These are the top bits:

    public float jumping = 12.0F;
    public int maxjumps = 2;
    int jumps;

    void Jump()
    {
        if (jumps > 0)
        {
            CharacterController controller = GetComponent<CharacterController>();

                if (Input.GetButtonDown("Jump"))
                {
                    moveDirection.y = jumping;

                    jumps = jumps - 1;
                }
            }
        if (jumps == 0)
        {
            return;
        }
    }

    void JumpReset()
    {
        CharacterController controller = GetComponent<CharacterController>();

        if (controller.isGrounded == true)
        {
            jumps = maxjumps;
        }
    }

BTW just play the functions in the update with:

        Jump();
        JumpReset();