How can I prevent my jump from looping?
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?
               Comment
              
 
               
              EDIT: I just saw your StackOverflow post, my solution probably wont work for a button since isn't updated on each frame, sorry, good luck
Answer by ronitrocket98 · Feb 23, 2019 at 01:40 AM
It should work, my guess is that the controller never detects its grounded. try using a trigger collider to test if its on the ground.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                