使物体平滑旋转不完全笔记

//旋转速度
public float RotateSpeed = 15;
private bool isTurn = true;
//private Vector3 newCameraRotate;
private Quaternion newCamRoatation;
private float RotateRemain;
void Update()
{
  if(isTurn) 
  {
    RotateRemain -= Time.deltaTime;
    //从当前位置以一定速度旋转到目标位置
    transform.rotation = Quaternion.Lerp(transform.rotation, newCamRotaion,Time.deltaTime*RotateSpeed);
    if(iRotateRemain <= 0)  
    {
      isTurn = false; 
       } 
      }
 }
 public void StartTurn(vector3 newRotate)
      {
       isTurn=true;
       //newCameraRotate = newRotate;
       //将向量transform的位置旋转到目标位置
       newCamRotation = transform.rotation * Quatrenion.Euler(newRotate);
       RotateRemain = 1;
      }

猜你喜欢

转载自blog.csdn.net/tubugs/article/details/82431940