I want Jump only on the ground But.. with double click.. still jump in the air.

//======================================================================  
    void Update ()
    {
        if (Input.GetMouseButtonDown (0))
        {
                Jump ();
        }
    }

    void Jump()
    {
     if (IsGrounded())
       {
        rigidBody.AddForce (Vector2.up * jumpforce, ForceMode2D.Impulse);
       }
    }

    public LayerMask groundLayer;

    bool IsGrounded()
    {
        if(Physics2D.Raycast(this.transform.position, Vector2.down, 0.2f, groundLayer.value))
            {
                return true;
            }
            else
            {
                return false;
            }
    }
//======================================================================

I want to know why the character jump continuously in the air.

I attached the file, please.(unity 5.6. beta 9)

Thank you.

4546168–421855–Leni’s Games.zip (1020 KB)

Most likely it’s because your raycast is too long. 0.2f is fairly long, depending on how tall your character is, and how far the jump moves the character. So, most likely when the second click occurs, the character is in the air, but still close enough to the ground that the raycast still hits the ground.

Either shorten the raycast, so it’s more precise, or add another private variable indicating when the last jump occurred. Then, in order to jump, they need to be both grounded, and a small amount of time needs to have passed since the last jump.