- Home /
 
 
               Question by 
               Zetlix · Dec 13, 2021 at 12:39 PM · 
                double jumpinput setting  
              
 
              Help. Can't figure out the new input system or double jump in general
Help. Can't figure out the new input system or double jump in general. I'm new to coding so would love some help! That would be amazing.
Currently using Starter Assets - Third Person Character Controller from unity asset store https://assetstore.unity.com/packages/essentials/starter-assets-third-person-character-controller-196526
     private void JumpAndGravity()
     {
         if (Grounded)
         {
             // reset the fall timeout timer
             _fallTimeoutDelta = FallTimeout;
             // update animator if using character
             if (_hasAnimator)
             {
                 _animator.SetBool(_animIDJump, false);
                 _animator.SetBool(_animIDFreeFall, false);
             }
             // stop our velocity dropping infinitely when grounded
             if (_verticalVelocity < 0.0f)
             {
                 _verticalVelocity = -2f;
             }
             // Jump
             if (_input.jump && _jumpTimeoutDelta <= 0.0f && _canDoubleJump == false)
             {
                 // the square root of H * -2 * G = how much velocity needed to reach desired height
                 _verticalVelocity = Mathf.Sqrt(JumpHeight * -2f * Gravity);
                 _canDoubleJump = true;
                 _input.jump = true;
                 Debug.Log("jump 1");
                 // update animator if using character
                 if (_hasAnimator)
                 {
                     _animator.SetBool(_animIDJump, true);
                 }
                 else if (_input.jump && _canDoubleJump == true)
                 {
                     _verticalVelocity = Mathf.Sqrt(JumpHeight * -2f * Gravity);
                     _input.jump = false;
                     Debug.Log("jump 2");
                 }
             }
             // jump timeout
             if (_jumpTimeoutDelta >= 0.0f)
             {
                 _jumpTimeoutDelta -= Time.deltaTime;
             }
         }
         else
         {
             // reset the jump timeout timer
             _jumpTimeoutDelta = JumpTimeout;
             // fall timeout
             if (_fallTimeoutDelta >= 0.0f)
             {
                 _fallTimeoutDelta -= Time.deltaTime;
             }
             else
             {
                 // update animator if using character
                 if (_hasAnimator)
                 {
                     _animator.SetBool(_animIDFreeFall, true);
                 }
             }
             // if we are not grounded, do not jump
             _input.jump = false;
         }
         // apply gravity over time if under terminal (multiply by delta time twice to linearly speed up over time)
         if (_verticalVelocity < _terminalVelocity)
         {
             _verticalVelocity += Gravity * Time.deltaTime;
         }
     }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
restrict number of double jumps 1 Answer
2D Character Controller Double Jump? 1 Answer
Double jump does not work why? 0 Answers