I am trying to figure out why this is not working. The issue is that the “DoubleJumpUnlocked && Input.GetKeyDown(KeyCode.W) && canDoubleJump” seems to only become true during one frame after pressing the ‘W’ button. Assume the DoubleJumpUnlocked is true and the canDoubleJump is true when I jump.
if (isGrounded())
canDoubleJump = false;
Debug.Log("Can Jump: " + canDoubleJump);// + " | Unlocked: " + DoubleJumpUnlocked + " | Is it working: " + (DoubleJumpUnlocked && Input.GetKeyDown(KeyCode.W) && canDoubleJump));
if (DoubleJumpUnlocked && Input.GetKeyDown(KeyCode.W) && canDoubleJump)
{
Debug.Log("Double Jumped.");
playerRigid.velocity = new Vector2(0, jumpForce / 2);
canDoubleJump = false;
}
if (isGrounded() && Input.GetKey(KeyCode.W))
{
playerRigid.velocity = new Vector2(0, jumpForce);
canDoubleJump = true;
}