using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AimSlerp : MonoBehaviour
{[SerializeField]
private Transform _cube;// 直接设置一个空间变量// Start is called before the first frame updatevoidStart(){}// Update is called once per framevoidUpdate(){
Vector3 directionToFace = _cube.position - transform.position;// 计算和目标的相对位置
Debug.DrawRay(transform.position, directionToFace, Color.green);// 画出个射线,用于 debug,其实位置为人物位置,然后设定方向,设定颜色
Quaternion targetRotation = Quaternion.LookRotation(directionToFace);// 获取对应的旋转角度
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime);// 转变旋转角度,第一个参数是开始的角度,第二个参数是目标角度,第三个参数是速度修正}}