第一种方式
private Vector3 offset;//记录小球到摄像机的偏移
public Transform player;
void Start () {
offset = this.transform.position-player.position ;
}
// Update is called once per frame
void Update () {
//刷新摄像机的位置,使其跟踪小球的位置
//v1==player.position
//v2==offset
this.transform.position = player.position + offset;
}
cp——offset
第二种
private Vector3 offset;//记录小球到摄像机的偏移
public Transform player;
void Start () {
offset = player.position-this.transform.position ;
}
// Update is called once per frame
void Update () {
//刷新摄像机的位置,使其跟踪小球的位置
//v1==player.position
//v2==offset
this.transform.position = player.position - offset;
}