📅  最后修改于: 2022-03-11 14:49:21.795000             🧑  作者: Mango
StartCoroutine(moveToPosition(yourTransform, newPosition, time));
public IEnumerator moveToPosition(Transform transform, Vector3 position, float timeToMove)
{
var currentPos = transform.position;
var t = 0f;
while (t < 1)
{
t += Time.deltaTime / timeToMove;
transform.position = Vector3.Lerp(currentPos, position, t);
yield return null;
}
}