1. 程式人生 > >使物體平滑旋轉不完全筆記

使物體平滑旋轉不完全筆記

//旋轉速度
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
; }