Question by
newt2017 · Dec 10, 2017 at 09:10 PM ·
transformeuleranglestransform.rotation
Rotating an object in script
I would like to rotate an object on angle defined in variable
_fighterAngles
This variable stores rotation angles in global coordinate system.
I do the following:
Quaternion rotation = Quaternion.Euler(_fighterAngles.x, _fighterAngles.y, _fighterAngles.z);
transform.rotation = rotation;
currAngles = transform.eulerAngles;
However, the variable have different values:
_fighterAngles = (90.0, -114.6, 139.8)
currAngles = (90.0, 105.6, 0.0)
As a result, my object is not rotated how I want, and the angles in the Inspector does not coincide with _fighterAngles.
I also tried to use localEulerAngles:
transform.localEulerAngles = _fighterAngles;
But it also didn't help and the values in the Inspector did not coincide with _fighterAngles. As a result my object is rotated in wrong direction.
How do I resolve a problem?
Comment