So i was trying to make an Air Dash ability to my character but in order to it to work i need to verify if the player stopped pushing the jump button (i want to do that by checking Input.GetButtonUp("Jump) value) but no matter what its always returning false. Same thing goes to the Input.GetButtonDown(“Jump”) value. Atp idk what im doing wrong.
Here’s a little example of what im doing:
private void Jump()
{
if (Input.GetButtonDown("Jump") && isGrounded) // Player starts pressing the button
isJumping = true;
if (Input.GetButtonUp("Jump") && !isGrounded) // Player stops pressing the button
jumpCancel = true;
// Normal jump (full speed)
if (isJumping)
{
verticalVelocity = jumpAcceleration * Time.deltaTime;
if (verticalVelocity >= maxJumpDuration)
{
isJumping = false;
}
}
// Cancel the jump when the button is no longer pressed
if (jumpCancel)
{
if (verticalVelocity < minJumpHeight)
{
verticalVelocity = jumpAcceleration * Time.deltaTime;
}
if(Input.GetButtonDown("Jump") && !isGrounded) //presses the jump button again while in the air
{
//AirDash();
}
if (isGrounded) jumpCancel = false;
}
// Aplica a velocidade vertical ao personagem
Vector3 verticalMovement = Vector3.up * verticalVelocity;
characterController.Move(verticalMovement * Time.deltaTime);
}