1
\$\begingroup\$

I have a scene in my game where you create your own designs by placing static meshes and manipulating their scales, positions, and rotations.

For the rotations I'm using Quaterion.AngleAxis as so:

        if (toolMode == PositioningTool.Rotate)
        {
            switch (grabbedCollider.transform.name)
            {
                case "X":
                    focus.localRotation *= Quaternion.AngleAxis(delta.x * 90 * Time.deltaTime, transform.right);
                    break;
                case "Y":
                    focus.localRotation *= Quaternion.AngleAxis(delta.x * 90 * Time.deltaTime, transform.up);
                    break;
                case "Z":
                    focus.localRotation *= Quaternion.AngleAxis(delta.x * 90 * Time.deltaTime, transform.forward);
                    break;
            }
        }

where delta is the mouse movement for that frame, focus is the object I am manipulating, and transform is the transform component of the ToolArm that the player interacts with. toolarm.position is set to focus.position every frame

my problem arises when I try to do a rotation on my x axis. my other axis will spin 360 and beyond, spinning in circles endlessly. when x axis is used, it only rotates from -90 to 90 (as seen in the unity editor). What am I doing wrong?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.