平滑移动

using UnityEngine;
using System.Collections;

public class Fllow : MonoBehaviour {

    // 先声明一个被跟随的目标
    public Transform play;

    public float smooth;

    void Update () 
    {
        // 设定跟随的位置,被跟随的坐标加上两者的坐标差
        Vector3 pos = play.position + new Vector3 (0, 0, -2);

        // 通过Vector3的Lerp来实现平滑移动,而不是一下子过去。第一个参数是当前坐标,第二个参数是将要到达的坐标,第三个是需要经历的时间
        transform.position = Vector3.Lerp (transform.position, pos, smooth * Time.deltaTime);
    }
}
原文地址:https://www.cnblogs.com/-soy/p/5917564.html