Hi, I just want to ask if there’s a way to prevent Unity from auto-rotating my game object. I’m trying to set up a game object that is rotated 180 degrees along its x-axis and the other axes are valued at 0. Now when I start the game, Unity then changes that object’s rotation to (0, 180, 180) automatically, even before I manipulate anything on the object. This really throws a wrench into my code, because I want to turn this object along the x-axis back to 0. Setting the object’s rotation via code to (180, 0, 0) does nothing and still gives me the (0, 180, 180) rotation - probably it’s the same graphically to Unity but again, it does nothing for what I want to do.
Any ideas or workarounds would be very much appreciated. Thanks!
This happens because rotations in Unity are actually Quaternions- they can’t be modelled sensibly with just 3 numbers. The (x,y,z) euler angle representation gives you just one way in which a given Quaternion can be converted into a 3-axis rotation, but in fact you can often create several equivalent 3-axis rotations which end up in the same place.
This is a good example of why it’s dangerous to assume that rotations work the way it looks like they do in the inspector- When the game begins, it converts the actual ‘rotation’ quaternion to euler angles, but in a different way- it’s not rotating anything, just changing the way you see it. You should either familiarise yourself with the way that Quaternions work, or use the Quaternion manupulation functions provided by the API, instead of modifying the values manually. Transform.Rotate and the like also manage the rotations properly internally, so if you use those it should work as well.