我必须将对象从 -10 移动到 +10 x 位置。但是我想从零 x.point 开始我的对象移动,我怎样才能在中间位置开始我的 lerp?
Edit2:对象应该从 x = 0 位置开始并移动到 +10 x 位置并转到 -10 x 位置,然后再次 +10 x、-10 x 像一个循环。
Vector3 pos1, pos2, pos0, pos3;
void Start()
{
pos0 = transform.position;
pos1 = pos0 + new Vector3(10, 0, 0);
pos2 = pos0 - new Vector3(10, 0, 0);
pos3 = pos1;
}
float time = 0.5f;
void FixedUpdate()
{
time += Mathf.PingPong(Time.time * 0.5f, 1.0f);
transform.position = Vector3.Lerp(pos2, pos1, time);
}