Since the CoyoteTimer()
method is already using CheckGrounded()
I don’t think there’s any reason to also call CheckGrounded()
in HandleJump()
That (very slightly) streamlines the code:
void CoyoteTimer()
{
if(CheckGrounded())
{
_coyoteTimer = _coyoteTime;
_doubleJumpAvailable = true;
}
else
{
_coyoteTimer -= Time.deltaTime;
}
}
void HandleJump()
{
if(!_frameInput.Jump) { return; }
if(_coyoteTimer > 0)
{
OnJump?.Invoke();
}
else if(_doubleJumpAvailable)
{
_doubleJumpAvailable = false;
OnJump?.Invoke();
}
}