Unity 3d 实现相机跟随
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class follow : MonoBehaviour
{
public GameObject palyer;
private Vector3 setting;
void Start(){
setting=transform.position-palyer.transform.position;//计算物体与相机之间的距离
}
void FixedUpdate(){
transform.position=setting+palyer.transform.position;//当player位置发生改变相机位置也相应发生改变
}
}