📜  unity 2d 平台游戏移动脚本刚体 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:32.148000             🧑  作者: Mango

代码示例1
float acceleration = grounded ? walkAcceleration : airAcceleration;
float deceleration = grounded ? groundDeceleration : 0;

// Update the velocity assignment statements to use our selected
// acceleration and deceleration values.
if (moveInput != 0)
{
    velocity.x = Mathf.MoveTowards(velocity.x, speed * moveInput, acceleration * Time.deltaTime);
}
else
{
    velocity.x = Mathf.MoveTowards(velocity.x, 0, deceleration * Time.deltaTime);
}