Quaternion.Slerp() Problem

81526-quaternion.png
why Quaternion.Slerp() function draw the green line, not the red line;

Slerp() is not make the shortest path?

if i want to rotate GameObject follow the red line, how can i do?

void Update(){
             Quaternion startRot = Quaternion.Euler(0, 0, 0);
             Quaternion targetRot = Quaternion.Euler(50, 200, 50);
             var startPos = startRot * (Vector3.forward * 4);
     
             for (int i = 0; i <= 20; i++)
             {
                 var rot = Quaternion.Slerp(startRot, targetRot, i / 20f);
                 var endPos = rot * (Vector3.forward * 4);
                 Debug.DrawLine(startPos, endPos, new Color(0, 1, 0, 1f));
                 startPos = endPos;
     
                 Debug.DrawLine(endPos, Vector3.zero, new Color(0, 1, 0, 0.2f));
             }
     }

Well, it is the shortest path. Keep in mind that you rotate in 3 axes. If it would rotate along the red path the quaternion would be upside down. So it needs an additional 180° rotation around the local z axis. The used rotation only rotates 160 around y and 50 around x and z.

Keep in mind that quaternion represent an orientation, not just a direction. Vector3.Slerp would do what you want, but of course only for one axis.

Hi @pplasto.

What are you trying to do with the Quaternion.Slerp() method ?

I have the feeling there must be a much simpler way to adchieve a movement interpolation with a rotation interpolation.