if (isMove)
{
//Move();
deltaVec = dir * moveSpeed * Time.deltaTime;
playerRgd.position += deltaVec;
deltaPlayerVec = playerRgd.position;
}
else
{
Vector2 curVec = transform.position;
if (isArrived==false)
{
playerRgd.position = Vector2.MoveTowards(curVec, deltaNewVec, Time.deltaTime* moveSpeed);
Debug.Log("distance:" + Vector2.Distance(playerRgd.position, deltaNewVec));
if (Vector2.Distance(playerRgd.position, deltaNewVec)<0.01f)
{
playerRgd.position = deltaNewVec;
isArrived = true;
}
}
}
当鼠标按下ismove为True的时候进行方向移动,抬起鼠标停止移动,move为false时进行了第二段移动到格子的中间,计算到格子中间的代码就不上传,偶尔移动的时候,会卡顿一下,几率还比较高 。请问老师知道啥原因么