- Home /
Question by
unity_IBRSwyeXkn-ezA · Oct 01, 2019 at 10:31 AM ·
rotationlerpsmoothworldspace
Lerp Rotation in World Space
I'm currently having trouble to apply rotations to an object in Unity. I'm using a Lerp to get smooth transition from rotation A to rotation B. The problem is: If i rotate the object around the y-axis, the roation around the x-axis is no longer relative to the camera.
I know that Transform.Rotate(rotationVector, Space.World) exists, but i want to keep the Lerp in for a smooth transition.
How can i combine a Quaternion.Lerp rotation with a rotation relative to the World Space?
void LateUpdate()
{
// update rotation
modelPivot.transform.localRotation = Quaternion.Lerp(modelPivot.transform.localRotation, Quaternion.Euler(rotationVector), Time.deltaTime * orbitDampening);
}
Comment
Answer by OlivierHoel · Oct 02, 2019 at 04:41 AM
Try
modelPivot.transform.rotation = Quaternion.Lerp(modelPivot.transform.rotation, Quaternion.Euler(rotationVector), Time.deltaTime * orbitDampening);
so that everything is in world space