Version: 2022.3
public static Vector2 Lerp (Vector2 a, Vector2 b, float t);

描述

在向量 a 与 b 之间按 t 进行线性插值。

参数 t 限制在范围 [0, 1] 内。

当 t = 0 时,返回 a 。
当 t = 1 时,返回 b 。
当 t = 0.5 时,返回 a 和 b 的中点。

另请参阅:LerpUnclamped。

using UnityEngine;

public class Example : MonoBehaviour { public Vector2 destination;

void Update() { //Moves the GameObject from it's current position to destination over time transform.position = Vector2.Lerp(transform.position, destination, Time.deltaTime); } }