按下一次移动按钮时,角色继续移动而不停止,除非按下另一个按钮 我想修改这段代码,让玩家只有在按下按钮时才会移动
public void Move(Vector3 velocity, bool standingOnPlatform)
{
Move(velocity, Vector2.zero, standingOnPlatform);
}
public void Move(Vector3 velocity, Vector2 input, bool standingOnPlatform = false, bool isPlayer = false)
{
UpdateRaycastOrigins();
isBelowOld = collisions.below;
collisions.Reset();
collisions.velocityOld = velocity;
playerInput = input;
if (velocity.x != 0)
{
collisions.faceDir = (int)Mathf.Sign(velocity.x);
}
if (velocity.y < 0)
{
DescendSlope(ref velocity);
}
if (HandlePhysic)
{
HorizontalCollisions(ref velocity);
if (velocity.y != 0)
{
VerticalCollisions(ref velocity);
}
}
if (collisions.left || collisions.right)
velocity.x = 0;
transform.Translate(velocity, Space.World);
if (standingOnPlatform)
{
collisions.below = true;
}
}
修改这段代码,让玩家只有在按下按钮时才会移动