I have a button which I press to jump. My problem right now is once I press this button once my Player just keeps jumping forever. But I want to make it so that I have to press the jump button again once I hit the ground. This is my current code:
public void onButtonJump()
{
if (controller.isGrounded )
{
verticalVelocity = -gravity * Time.deltaTime;
{
verticalVelocity = jumpForce;
animator.SetBool("is_in_air", true);
jump.Play();
}
}
else
{
animator.SetBool("is_in_air", false);
verticalVelocity -= gravity * Time.deltaTime;
}
}
How do i prevent this from looping and do so that I have to press the button again once I am grounded?