Making transform.Rotate more smooth?

I have some java script code that rotates a object. I works good but it just jerk’s to the rotation instantly. Is there a way to make it rotate more smoothly?

transform.Rotate(0,0,4,Space.Self);

Use a smaller amount; see the examples in the docs. Or use Quaternion.Slerp instead.

–Eric

with Quaternion.Slerp how do you set axis? I checked the reference

// 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);
}

Does this mean you have to create 2 Empty object and have one straight up and down and one rotated on the angle you wish to aquire?

You don’t need to create objects, you just use the rotations you want.

–Eric

k This is what i tried.

    transform.rotation =
      Quaternion.Slerp(0,4,Time.time * 0.1);

Its giving me this error.
Is not compatible with argument list ‘(int,int,float)’

See the docs for Slerp; 0 and 4 aren’t quaternions.

–Eric

Sorry eric but i am so confused. Does Quaternion.Slerp make it rotate substantially smoother? What are quaternions for slerp?

http://wiki.unity3d.com/index.php?title=MoveObject

–Eric

Thanks a lot eric5h5!!! My rotation looks so smooth now!!!

Hii… can you send me code of smooth rotation. Thanx