如何实现类似于Alto Adventure的2D跳跃?

时间:2018-08-28 06:54:08

标签: c# unity3d game-physics

我已经通过更改变换以及通过应用速度来实现,但是并没有达到那种平滑度。

 // 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;
}

0 个答案:

没有答案