using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MainCameraCtr : MonoBehaviour {
public int Speed;//定义速度变量
public Transform TagTransform;//要跟随的物体
private Vector3 offset;//一个向量,即摄像机与物体间的差值// Use this for initializationvoid Start (){
Speed =5;//定义速度为5
offset = transform.position - TagTransform.position;//摄像机与物体间的差值}// Update is called once per framevoid Update (){}voidLateUpdate(){
Vector3 newpos = TagTransform.position + offset;//摄像机新的位置信息为跟随物体的坐标+差值//线性插值,在 Speed * Time.deltaTime摄像机位置移动从之前位置开始到newpos结束
transform.position = Vector3.Lerp(transform.position, newpos, Speed * Time.deltaTime);}}