- Home /
 
Rotation always changing values!
 Vector3 rot = transform.localEulerAngles;
        if(Input.GetKey(KeyCode.P))
        {
          rot.y = 160.0f;
  
          mouseLook.enabled = false;
          theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, Quaternion.Euler(rot), Time.deltaTime * 10);
        }
  
        else
        {
          mouseLook.enabled = true;
          theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, Quaternion.identity, Time.deltaTime * 10);
        }
 
               How do I fix the camera rotation so that it will not change all the time if localRotation.y will reach to zero after I released the "P" button
It's because you're animating wrong; you're using 10 * Time.deltaTime, which is almost constant and only varies slightly each frame, ins$$anonymous$$d of allowing the interpolation parameter to depend linearly on time. Use Time.time ins$$anonymous$$d and set some initial startTime, then count up each frame from there.
Answer by The Kracken · Dec 10, 2013 at 02:25 AM
 float timeframe = 0;
 timeframe += Time.deltaTime/10.0f; //lets rotate over 10 seconds
 theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, Quaternion.Euler(rot), timeframe);
 
               timeframe needs to go from 0-1 to complete the slerp. when you do Time.deltaTime*10, its only staying at around the value of dt*10 and not going from 0-1;
Your answer
 
             Follow this Question
Related Questions
Need help on the 3ds max style camera control 0 Answers
Mouse.position from center of player 1 Answer
Smooth camera rotation on mobile and pc when GetMouseButton()? 0 Answers
Limiting the rotation to 180 degrees 0 Answers
Gameobject Rotation Calculation 0 Answers