- Home /
Double Jumping Occasionally Not Working
I have a third person controller based off of the Unity 5 standard third person, which I have augmented for our needs. I added a double jump, which can be seen in the scripts below, the issue is that it doesnt always register. The player has performed the first jump, is no longer grounded, a double jump bool is set to true but nothing happens. It doesn't happen every the time, but frequently.
Any help or input on this would be very much appreciated.
void HandleAirborneMovement()
{
m_GroundCheckDistance = 0.01f;
// apply extra gravity from multiplier:
Vector3 extraGravityForce = (Physics.gravity * m_GravityMultiplier) - Physics.gravity;
m_Rigidbody.AddForce(extraGravityForce);
m_GroundCheckDistance = m_Rigidbody.velocity.y < 0 ? 0.01f: m_OrigGroundCheckDistance;
if (jumpCounter < 2 && Input.GetButtonDown("Jump") ) {
// jump!
m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, m_JumpPower, m_Rigidbody.velocity.z);
m_Animator.SetBool("Jump", true);
m_IsGrounded = false;
jumping = true;
m_GroundCheckDistance = 1;
fallJump = false;
dblJump = false;
jumpCounter++ ;
}
}
void HandleGroundedMovement(bool crouch, bool jump)
{
// check whether conditions are right to allow a jump:
if (jump && jumpCounter == 0 )
{
m_Animator.SetBool("Jump", true);
// jump
m_Rigidbody.velocity = new Vector3(m_Rigidbody.velocity.x, m_JumpPower, m_Rigidbody.velocity.z);
jumping = true;
m_IsGrounded = false;
jump = false;
dblJump = true;
jumpCounter++ ;
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Even / Constant Speed and Jumping 2D 1 Answer
Advanced jumping 0 Answers