- Home /
Quaternion.Slerp over time
im running the following inside a Coroutine
//startRotation and endRotation are cached rotations from two different Transforms var t = 0; while(t < rotationDuration) { yield return null; t += Time.deltaTime; mRoot.rotation = Quaternion.Slerp(startRotation, endRotation, Time.time * 5f); }
mRoot.rotation = mPath.rotationEnd.rotation;
which works fine for the rotation itself. Now I tried to do the rotation "over time" using this
//this is calculated before the while() loop
var angle = Quaternion.Angle(startRotation, endRotation) ;
var rate = angle / rotationDuration;
and plugging this into the Slerp function in this way.
mRoot.rotation = Quaternion.Slerp(startRotation, endRotation, Time.deltaTime * rate);
but all I get on the GO to be rotated is a jitter, no actual rotation. Any pointers in the right direction would be appreciated.
Answer by Eric5h5 · Jan 25, 2011 at 06:11 AM
"Time.time * 5f" won't do anything after the first second of runtime, since Slerp uses the usual 0..1 range for the third parameter. For correct usage, see the Rotation function here.
thanks for the script, pointed me in the right direction. I ended up using Quaternion.Slerp(startRotation, endRotation, $$anonymous$$athf.Clamp01(t/rotationDuration)); but that basically is the same idea.
Your answer
Follow this Question
Related Questions
Use Lerp to rotate object 2 Answers
Follow and Rotate an object 1 Answer
Best rotation function to use 1 Answer
Rotating Rigidbodies 2 Answers