CodeCamraFollow12345678910111213141516171819202122using System.Collections;using System.Collections.Generic;using UnityEngine;public class CameraFollow : MonoBehaviour { //跟随目标 public Transform _target; //平滑系数 public float smoothing; //跟随速度 private Vector3 velocity; //写在LateUpdate中 void LateUpdate () { if (_target != null) { this.transform.position = Vector3.SmoothDamp(this.transform.position, _target.transform.position, ref velocity, smoothing); } }}