My 3D character is flying up when I jump

Hello!

When I jump with my 3D character and I press several times space (jump), then my character fly up in the air. What’s the problem ? :confused: On the object have mesh collider.

My jump script in FixedUpdate:

if (grounded == true && Input.GetAxis("Jump") > 0)
        {
                grounded = false;
                rb.AddForce(new Vector3(0, jumpHeight, 0));
                print("JUMP");
                actions.Jump();
        }

        //check if we are grounded   
        groundCollisions = Physics.OverlapSphere(groundCheck.position, groundCheckRadius, groundLayer);
        if (groundCollisions.Length > 0) grounded = true;
        else grounded = false;

As @Cherno says, you need to add a cooldown…

Add a float to the variables to the top, as float timeCounter; and add the following script to the top of the FixedUpdate or Update (whatever you’re using)

timeCounter += -1 * Time.deltaTime;

Then replace your rb.AddForce(new Vector3(0, jumpHeight, 0)); with the following script

if (timeCounter < 0) {
      timeCounter = 0.5f; // Or whatever delay you want
      rb.AddForce(new Vector3(0,jumpHeight,0));
      actions.Jump();
      print("Jump");
}