public bool StartMove = false;//相机是否开始移
private Vector3 v1 = new Vector3(1.689003f, 1.730917f, -26.12957f);//相机初始位置
private Vector3 v2;//相机目标位置
private Quaternion r1 = Quaternion.Euler(0.9f, -0.3f, -0.005f);//相机初始角度
private Quaternion r2;//相机目标角度
public float angle;//相机初始角度和目标角度的差值
public List<Vector3> Route = new List<Vector3>();//相机移动路径储存
public List<Quaternion> Ro = new List<Quaternion>();//相机移动路径角度储存
public int dse_num = 0;
private void Update()
{
//print(itemPanelList.Count);
Change_Panel();
if (StartMove)//相机初始位置到目标位置的推进
{
if (Route.Count>0)
{
//dse = Vector3.Distance(c.transform.position, Route[dse_num]);
//
//Vector3.MoveTowards()平移
c.transform.localPosition = Vector3.MoveTowards(c.transform.localPosition, Route[dse_num], 3f * Time.deltaTime);
//Quaternion.RotateTowards()转向
c.transform.localRotation = Quaternion.RotateTowards(c.transform.localRotation, Ro[dse_num], 70f * Time.deltaTime);
// Vector3.Angle()计算角度 返回的角度总是两个向量之间的较小的角
angle = Vector3.Angle(new Vector3(c.transform.localRotation.x, c.transform.localRotation.y, c.transform.localRotation.z), new Vector3(Ro[dse_num].x, Ro[dse_num].y, Ro[dse_num].z));
print(angle);
//angle = Vector3.SignedAngle(new Vector3(c.transform.localRotation.x, c.transform.localRotation.y, c.transform.localRotation.z), new Vector3(Ro[dse_num].x, Ro[dse_num].y, Ro[dse_num].z), c.transform.forward);
//c.transform.transform.Rotate(new Vector3(0, angle * 2 * Time.deltaTime, 0), Space.World);
if (angle <=0.03f&& c.transform.localPosition == Route[dse_num])
{
dse_num++;
}
//清除
if (dse_num == Route.Count)
{
dse_num = 0;
Route.Clear();
Ro.Clear();
StartMove = false;
}
}
}
}