Answers for "localRotation rotates by 180°"
http://answers.unity.com/questions/1564826/localrotation-rotates-by-180.html
The latest answers for the question "localRotation rotates by 180°"Answer by JVene
http://answers.unity.com/answers/1564841/view.html
There is a lot one could say about what is wrong here, but let's start with the last line because that leads to an understanding that fixes everything else.
It appears you're familiar with Euler angles (your first line in the code block), but when you fashion a Quaternion (in the last line), you're fashioning the Quaternion with 4 parameters, and they are not Euler angles. Nothing in the constructor of a Quaternion will make much sense if you're not really familiar with the mathematics of quaternions (the subject of math beyond that of Unity). A quaternion (and thus Unity's Quaternion class) represents a complex number, like the imaginary numbers taught in algebra whereby the square root of a negative number becomes possible. The complex numbers taught in algebra are generally related to a 2 dimensional representation (like the imaginary numbers which have two values, an imaginary part and a real part). Quaternions, however, are complex numbers in 3 dimensions. None of the 4 parameters (x,y,z,w) have any meaning relative to rotations in Euler angles. This is the problem you're having. You are providing a value you intend to interpret as an angle in degrees, but the y parameter to the Quaternion constructor has no relationship to such an angle in the y axis.
----------
To fix that, and therefore propagate that upwards to the rest of your code, look up the static function Quaternion.Euler, which forms a correct Quaternion object given Euler angles in 3 axis, as you're expecting. You could also consider using the eulerAngles property of localRotation as an alternative approach, or at the least in your translation between any quaternion and an orientation in 3 axis.Mon, 22 Oct 2018 17:30:36 GMTJVene