Vector3.Lerp 线性插值
C# => static Vector3 Lerp(Vector3 from, Vector3 to, float t);
Vector3.MoveTpwards 移向
C# => static function MoveTowards(current: Vector3, target: Vector3, maxDistanceDelta: float): Vector3;
当前地点移向目标
Vector3.SmoothDamp 平滑阻尼
C# => static Vector3 SmoothDamp(Vector3 current, Vector3 target, Vector3 currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity, float deltaTime = Time.deltaTime);
随着时间的推移,逐渐改变一个向量朝向预期的方向移动
向量由一些像弹簧阻尼器函数平滑,这将用远不会超过,最常见的用途是跟随相机
实现跟随鼠标运动
public class Demo : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// 此时的摄像机必须转换 2D摄像机 来实现效果(即:摄像机属性Projection --> Orthographic)
Vector3 dis = Camera.main.ScreenToWor