- Home /
Why Is Rotation Different For RectTransform?
I'm working on translating the H/V input from a PS4 controller into a heading. I will use this to change the direction of the player as they are walking. I also built a debug panel that will show me the value of the horizontal/vertical inputs and the calculated heading. I got this to work for the debug panel before I applied it to the player. They are very similar-
Player-
Quaternion primaryHeading;
if(InputUtils.GetPrimaryHeading(out primaryHeading))
{
transform.rotation = primaryHeading;
}
Debugger-
if(InputUtils.GetPrimaryHeading(out primaryHeading))
{
JoyLeftValue.GetComponent<Text>().text = primaryHeading.eulerAngles.y.ToString();
Quaternion uiHeading = Quaternion.Euler(0, 0, primaryHeading.eulerAngles.y);
LeftJoyCompass.transform.rotation = uiHeading;
}
In the below gif I am moving the left analogue stick clockwise. Moving from 360 degrees to 0 degrees. The direction in the debug menu is correct, but the direction the player faces is not.
true north is to the right from this perspective.
As you can see, the degrees are calculated correctly and displayed in the debug. Applying the same rotation to a game object had an unexpected outcome. It looks like RectTransform is using standard degrees where 90 is at the top, and 0 is on the right and the degrees should decrease moving clockwise. For a game object, 0 is at the top and the degrees increase moving clockwise.
Why are these different and how can I convert this-
To this-
Or vice versa