一:相机跟随
——直接把相机作为要跟随物体的子物体
我在制作小地图相机的时候一般这样用其他的情况都不推荐
——计算偏移量求出相机正确的实时位置
using UnityEngine;
public class CameraController : MonoBehaviour
{
public Transform targetPos;//跟随物体的位置
private Vector3 offset;//偏移量
private void Start()
{
offset = transform.position - targetPos.position;
}
private void LateUpdate()
{
transform.position = offset + targetPos.position;
}
}
——算是方法2的升级版(插值移动)
using UnityEngine;
public class CameraController : MonoBehaviour
{
public Transform targetPos;//跟随物体的位置
private Vector3 offset;//偏移量
public float smooth;//平滑度
private void Sta