Hello everyone. I’m currently trying to get a jumping control setup for a character, but it’s not going quite as smooth as I was hoping.
// FixedUpdate
void FixedUpdate () {
//grounded + anim
grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
myAnim.SetBool ("isGrounded", grounded);
//doublejump reset
if (grounded)
doubleJump = false;
jumping = false;
//jumping?
if (!grounded)
jumping = true;
}
//Update
void Update(){
//jumping
if ((grounded || !doubleJump) && Input.GetButtonDown("Jump")){
GetComponent<Rigidbody2D> ().AddForce (new Vector2 (0, jumpForce));
myAnim.SetBool ("isGrounded", grounded);
//doublejump
if(!doubleJump && !grounded)
doubleJump = true;
jumping = true;
}
}
}
I can jump just fine, but my problem is when I double jump the height is different depending on where in the jump arc the second jump input is used.
If I press it quickly, I jump rather high, and if I press it right before I hit the ground it turns into more of a pause than a jump. Any tips would be appreciated… still trying to get the hang of this stuff.