我已经通过更改变换以及通过应用速度来实现,但是并没有达到那种平滑度。
// In Update
if (Input.GetKeyDown("space"))
{
isJumping = true;
StartCoroutine(Jump());
isJumping = false;
}
IEnumerator Jump()
{
if (IsGrounded())
{
isJumping = true;
player.gravityScale = gravityDuringJump;
player.velocity = new Vector2(jumpSpeedInX, jumpSpeedInY);
}
yield return new WaitUntil(() => IsGrounded() == false);
isJumping = false;
}