Double Jump NoT Working
So i was working on my double jump system but it cant double jump i am a complete beginner and i dont know what causes this please help
My Code: using System.Collections; using System.Collections.Generic; using UnityEngine;
public class PlayerMovement : MonoBehaviour { public ParticleSystem dust; public float runSpeed = 35f; float horizontalMove = 0f; public CharacterController2D controller2D; public Animator animator; private int extraJumps; public int jumpValue; bool jump = false; bool crouch = false; private bool grounded; public Transform groundCheck; public float checkRadius; public LayerMask whatIsGround;
 void Start()
 {
     extraJumps = jumpValue;
 }
 void Update()
 {
     horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
     animator.SetFloat("Speed", Mathf.Abs(horizontalMove));
     if (grounded == true)
     {
         extraJumps = jumpValue;
     }
     
     if (Input.GetButtonDown("Jump") && extraJumps > 0)
     {
         jump = true;
         animator.SetBool("isJumping", true);
         extraJumps--;
     }else if (Input.GetButtonDown("Jump") && extraJumps == 0 && grounded == true)
     {
         jump = true;
         animator.SetBool("isJumping", true);
     }
     if (Input.GetButtonDown("Crouch"))
     {
         crouch = true;
     }else if (Input.GetButtonUp("Crouch"))
     {
         crouch = false;
     }
     if (horizontalMove == 35f)
     {
         CreateDust();
     }else if (horizontalMove == -35f)
     {
         CreateDust();
     }
     
      
     
 }
 public void OnLanding()
 {
     animator.SetBool("isJumping", false);
 }
 public void OnCrouching(bool isCrouching)
 {
     animator.SetBool("isCrouching", isCrouching);
 }
 void FixedUpdate()
 {
     grounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
     controller2D.Move(horizontalMove * Time.fixedDeltaTime, crouch, jump);
     if (grounded == true)
     {
         jump = false;
     }
 }
 
 void CreateDust()
 {
     dust.Play();
 }
 void StopDust()
 {
     dust.Stop();
 }
 
               }
Answer by patatra · Jan 26 at 10:32 AM
Hi there, (I'm not a pro) I think your problem is the else if
      if (Input.GetButtonDown("Jump") && extraJumps > 0)
      {
          jump = true;
          animator.SetBool("isJumping", true);
          extraJumps--;
          if (Input.GetButtonDown("Jump") && extraJumps == 0 && grounded == true)
             {         
              jump = true;
              animator.SetBool("isJumping", true);
              }
      }
 
              Answer by Ali_Fuat_ADAK1 · Jan 26 at 02:55 PM
Nope that wouldnt work
 if (Input.GetButtonDown("Jump") && !Double Jump)
       {
           jump = true;
           
           
           if (Input.GetButtonDown("Jump")&& jump )
              {         
               Double Jump=true;
               
               }
       }
 
                  And in doing so?
Your answer