I need help to remove double jump

I need help to remove double jump. This is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerMovment : MonoBehaviour
{

    public CharacterController2D controller;

    public float runSpeed = 40f;

    float horizontalMove = 0f;

    bool jump = false;
    bool chouch = false;


    void Update ()
    {
        horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;

        if (Input.GetButtonDown("Jump"))
        {
            jump = true;
        }

        if (Input.GetButtonDown("chouch"))
        {
            chouch = true;
        } else if (Input.GetButtonUp("chouch"))
        {
            chouch = false;
        }
    }

  
    void FixedUpdate ()
    {
        controller.Move(horizontalMove * Time.fixedDeltaTime, chouch, jump);
        jump = false;
    }
   
}

Go look up any number of a bazillion scripts that check if you are on the ground to prevent you from jumping when you are not on the ground. Here’s one example… there are thousands of others, including Youtube tutorials:

1 Like

no I want to fix the script that allredy have

He told you how to do it. And he mentioned examples you can reference. Checking if you can jump is the fix for removing double jump.

2 Likes

Excellent! Go for it. The other script will show you precisely what you need to add to yours.

1 Like

um… I need help on that too, if you know how to fix it can you plz do it for me :(:(;):(;):(:):eyes: