u3d使摄像机跟随物体
using UnityEngine;
using System.Collections;
public class Movefollo : MonoBehaviour {
Transform _player;
Vector3 f;
// Use this for initialization
void Start () {
_player= GameObject.Find("Sphere").transform;
f = transform.position - _player.position; //初始时获得物体与相机间的相对位置
}
// Update is called once per frame
void Update () {
transform.position = _player.position + f; //移动时用物体的位置加上开始的相对位置
}
}