Thank you!
I'd like to add that after I used this code in mine, my character seemed to have a unintended delay/cooldown on his jump.
I think is_on_floor()
wasn't being updated on time because the while
loop was slowing the code by waiting the condition to end.
And my character reached the ground before the loop was done.
Writing this on the next line afteryield()
fixed it.
if is_on_floor():
break
Resulting in
while lerp_amount < 1:
lerp_amount += delta
motion.y = lerp(-800, gravity, lerp_amount)
yield(get_tree(), "idle_frame")
if is_on_floor():
break