I am using Unity3D. I would like to rotate the object in the direction of the mouse pointer, but allow the maximum rotation speed, for example, "max 100 degrees per second".
There is an example in the document, but it does not do what I want.
I think Time.time should be Time.deltaTime, and I cannot figure out what the last parameter does. Is it supposed to be a number that sums with the start vector?
http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Slerp.html
Also, I cannot figure out what the last parameter does. Is it time for a spin?
The code I'm using now
Plane plane = new Plane(Vector3.up, 0);
float dist;
void Update () {
Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
if (plane.Raycast(ray, out dist)) {
Vector3 point = ray.GetPoint(dist);
Vector3 direction = (point - transform.position).normalized;
Quaternion lookRotation = Quaternion.LookRotation(direction);
transform.rotation = Quaternion.Slerp(transform.rotation, lookRotation, Time.deltaTime * rotationSpeed);
}
}
I think the weak point is in the third parameter of Slerp, but I can’t figure out what to put there.