//1.向量转四元数
//Quaternion.LookRotation(dir);—>返回值就是一个四元数
//2.开始旋转
//transform.rotation = Quaternion.Lerp(当前的四元数, 目标四元数, 旋转的速度);
//3.普通相机跟随
/////////////////////////////////////////// 方法一 ///////////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMovement : MonoBehaviour {
///
/// 跟随目标
///
public Transform followTarget;
///
/// 方向向量
///
private Vector3 dir;
private void Start()
{
//获取方向向量
dir = transform.position - followTarget.position;
}
private void Update()
{
transform.position = dir + followTarget.position;
}
}
/////////////////////////////////////////// 方法二 ///////////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMovement : MonoBehaviour {