Good day. I met a problem, with that rotation, exactly in 360 degrees by one of the axis. (in my case- yAxis)
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…
In my case I working with world space UI. Here is example at picture:
- step - clicking and put 1st point
- 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
- step - mouse click and set 2nd arrow point
I use
transform.eulerAngles = new Vector3(90, followMouse.eulerAngles.y, 0);
but anyway, if I calculate rotation from
Quaternion followMouse = Quaternion.FromToRotation(Vector3.right, endPoint - startPoint);
I got a bug in 360 degrees position. At that point that is
Debug.Log: followMouse.eulerAngles.y: 1.332716E-05
What to do? How to rotate correctly in 0/360 degrees?