Quaternion vs transform.forward

Hi, just a quick question here.

I found using the Quaternion works nicer. Are there any advantages of using transform.forward directly other than simplicity?

Did anyone else find the rotation movement a little odd with the changing forward transform? With me, at times it looked great and at other times the character walked backward almost the entire way regardless of the setting of the rotationSpeed variable.

            //transform.forward = Vector3.Lerp(transform.position, moveDirection, Time.deltaTime * rotationSpeed);

            Quaternion rotation = Quaternion.LookRotation(moveDirection);
            Quaternion current = transform.localRotation;
            transform.localRotation = Quaternion.Slerp(current, rotation, Time.deltaTime * rotationSpeed);

8 Likes

Both are valid methods for rotating an object. Personally I still find Quaternions quite confusing so I prefer working with Vectors but if you like Quaternions then yup go ahead and do it like that.

The issue you are talking about, is that mainly when rotating 180º? Sometimes it takes a while to rotate? Yup that’s the negative side effect of using the Vector method, basically as the Vector is Lerping to the target (when doing a near 180º rotation) it gets smaller in magnitude as it approaches 0,0 and then suddenly rotates when it passes 0,0.
Using the Quaternion method does indeed avoid that side effect since it’s always working with rotations.

5 Likes

Thank you @Velcronator
The animation is much better now.
(using Quaternion is always a burden for me)

3 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms