I'm making a 2D platformer controller and I want to implement a coyote time and buffered jump, the way I implement both is by setting a bool to true when either action is enabled like this:
private IEnumerator ApplyCoyote()
{
isCoyote = true;
yield return coyoteDelay;
isCoyote = false;
}
So if you were to press jump while isCoyote
is true you would jump.
But every now and then the coroutine appears not to work and isCoyote
becomes false immediately.
I confirmed this by logging the changes to isCoyote
and most of the time I can notice the delay between it becoming true and false plus the time on both logs is different, but when it fails it just prints them at the same time.
BTW I'm not disabling any scripts and I stop any previous calls to this coroutine before starting a new one
bool isCoyote => timeSinceGround <= coyoteDuration;
orbool isCoyote => (Time.time - lastGroundTime) <= coyoteDuration;
\$\endgroup\$Debug.Log("isCoyote = true");
? \$\endgroup\$