我们分别在工程里两个对象Player,pet
之后分别表写两个脚本首先 是pet脚本写完把它拖拽到pet游戏对象身上,下面代码 可供 参考
//宝宝跟随的目标
public Transform target;
//宝宝跟随目标的偏移量
public Vector3 offset;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Debug.Log(Vector3.Lerp(new Vector3(0, 0, 0), new Vector3(0, 0, 10), Time.deltaTime));
}
void LateUpdate()
{
offset = target.forward * -2 + target.up * 2;