- Home /
trouble with Quaternion rotation in 360 axis degree
Good day. I met a problem, with that rotation, exactly in 360 degrees by one of the axis. (in my case- yAxis) Here is a code, how I rotate my object
Quaternion followMouse = Quaternion.FromToRotation(Vector3.right, endPoint - startPoint); Quaternion newQuar = Quaternion.AngleAxis(90, Vector3.right); arrow.transform.rotation = followMouse * newQuar;
So, I got 2 point xPlane, getting angle in Quaternion, from last point to first, and after adding rotation by xAxis (that is always 90 degress) I got troubles only in 1 position, when get 360 degrees in yAxis rotation. At that moment my arrow starts to rotate in all axis by strange values, like 270, 90 degrees..
I found information, that it is kind of problem rotating with Quaternion, but how to solve that problem?
Hello,
What is the context of this issue? what are you trying to rotate, on what purpose? Because Depending on the situation different solutions could come up to perform a rotation.
And do you really have to use Quaternions?
In my case I working with world space UI. Here is example at picture 1 step - clicking and put 1st point 2 step - arrow following cursor. Here is going arrow rotation, and if I got 360 (or 0) degrees by y axis, I get that bug with rotations 3 step - mouse click and set 2nd arrow point
So, for sure I can use
transform.eulerAngles = new Vector3(90, follow$$anonymous$$ouse.eulerAngles.y, 0);
but anyway, if I calculate rotation from
Quaternion follow$$anonymous$$ouse = Quaternion.FromToRotation(Vector3.right, endPoint - startPoint);
I got a bug in 360 degrees position. At that point that is
Debug.Log: follow$$anonymous$$ouse.eulerAngles.y: 1.332716E-05
Your answer
