把以下代碼綁定到攝像機
using UnityEngine;
using System.Collections;
public class FollowTarget : MonoBehaviour {
public Transform playerTransform; //把運動物體拖放到此處
private Vector3 offset;
// Use this for initialization
void Start () {
offset = transform.position - playerTransform.position; //計算初始物體與相機的偏移距離
}
// Update is called once per frame
void Update () {
transform.position = playerTransform.position + offset; //運動物體當前位置 加上 原始偏移
}
}