- Home /
How do I transition smoothly between two lerps/slerps?
How do I smoothly transition from one lerp/slerp to another while the first is still in progress? Currently the code just stops the object rotation before starting the second.
The code so far:
if (rotating)
{
rotationTime += Time.deltaTime * RotationSpeed;
myRigidBody.transform.rotation = Quaternion.Lerp(myRigidBody.transform.rotation, DesiredDirectionOfTravel, rotationTime);
}
if (rotationTime >= 1.0f)
{
rotating = false;
}
Answer by JedBeryll · Jan 16, 2018 at 07:07 AM
If you want multiple rotations you could use Quaternion.LerpUnclamped. Or replace rotating = false;
with rotationTime = 0f;
No change when replacing rotating = false;
with rotationTime = 0f;
Not sure how using LerpUnclamped would change anything. Could you explain?
Wouldn't LerpUnclamped move it further along the line? Anyway maybe i'm just not understanding what you're doing here.
I'm looking for a smooth transition between rotations.
Lets say my current rotation is A and I'm rotating towards B. Half way through that rotation I want to rotate to C. Currently the code stops the AB rotation before starting the AC rotation.