- Home /
[QuaternionSlerp] Lookback script
Quaternion currentRotation = Quaternion.Euler(0, 0, 0);
Quaternion rotation = Quaternion.Euler(0, 140, 0);
if(Input.GetKeyDown(KeyCode.P))
theCamera.localRotation = Quaternion.Slerp(rotation, currentRotation, Time.deltaTime);
if(Input.GetKeyUp(KeyCode.P))
theCamera.localRotation = Quaternion.Slerp(currentRotation, rotation, Time.deltaTime);
Camera not slerping/lerping when i press "P" it will just rotate instantly.
Comment
Answer by robhuhn · Dec 06, 2013 at 03:01 PM
try following:
if(Input.GetKeyDown(KeyCode.P))
theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, currentRotation, Time.deltaTime);
if(Input.GetKeyUp(KeyCode.P))
theCamera.localRotation = Quaternion.Slerp(theCamera.localRotation, rotation, Time.deltaTime);
Works great but the Camera.locaRotation.y is always changing
Your answer
Follow this Question
Related Questions
3D menu camera rotation issue. 0 Answers
Use lerp or translate 1 Answer
Rotating object around Z axis with lerp/slerp 1 Answer
Transition current camera rotation to 0,0,0 1 Answer
Use Lerp to rotate object 2 Answers