void Update()
{
isGrounded = myFeet.IsTouchingLayers(LayerMask.GetMask("Ground"));
Jump();
if(jumpTimer > 0) jumpTimer -= Time.deltaTime;
if (isGrounded && jumpTimer <= 0){
coyoteTimer = maxCoyoteTimer;
}
if (coyoteTimer > 0) coyoteTimer -= Time.deltaTime;
if (jumpBuffer > 0) jumpBuffer -= Time.deltaTime;
}
void OnJump(InputValue value){
jumpInput = value.isPressed;
jumpBuffer = maxJumpBuffer;
}
void Jump(){
if (coyoteTimer > 0 && jumpBuffer>0 ){
coyoteTimer = 0;
jumpBuffer = 0;
jumpTimer = jumpCooldown;
myRigidbody.AddForce(new Vector2(0,jumpForce*100));
}
}
Here’s my script. The solution that i have in mind is to use a timer and when jumpInput = true, I start the timer. Then if the timer reaches a maximum amount, I stop adding force.
I just dont know how to fit that with my coyote timer and jump buffer.
Basically the coyote timer allows to jump a split second after not touching ground
and jump buffer allows to press jump a split second before touching ground