Question by
LoKko_777 · Oct 30, 2017 at 01:32 PM ·
camera rotateslerp
Rotating camera smoothly with Q & E (using Slerp)
Hi everybody,
I have a problem using Slerp function. Using this script for rotating a camera around the player is working fine:
var speed = 30;
function Update () {
if(Input.GetKeyDown("q")){
transform.Rotate(Vector3.up * 90 * speed * Time.deltaTime, Space.World);
}
if(Input.GetKeyDown("e")){
transform.Rotate(Vector3.up * 90 * -speed * Time.deltaTime, Space.World);
}
}
But the camera is transformed directly to the position. I have read that using Quaternion slerp function should make it go smoothly, using the example here:
// Interpolates rotation between the rotations "from" and "to"
// (Choose from and to not to be the same as
// the object you attach this script to)
var from : Transform;
var to : Transform;
var speed = 0.1;
function Update () {
transform.rotation = Quaternion.Slerp (from.rotation, to.rotation, Time.time * speed);
}
source: https://docs.unity3d.com/ScriptReference/Quaternion.Slerp.html
My problem is that even including a transform position to achieve this it is not being smooth but abruptly. Is any way to say that the value 90 is going to be the transform position?
Comment