- Home /
I can't set the rotation of an object, either with scripts or directly in the editor.
I'm running into a strange issue -
I have two directional lights, whose rotations I'm attempting to set in a script (C#)
I've created a transform Array which the two lights are assigned to. I've also created a new Vector 3 to store my rotation. (private Vector3 lightVector = (180, 270, 180);
When trying to set the rotation using the vector (light[0].transform.localEulerAngles = lightVector, and light[1].transform.localEulerAngles = lightVector) one of the two lights is set correctly.
The other light ends up rotated to (-5.0089e-06, 90.00001, 5.00897e-06)
And - even stranger, when I end the game and return to the editor, the rotation of the problematic light ends up set to some arbitrary numbers (0, 90, 0) rather than the numbers I set initially inside of the editor.
Whats going on here?
This is the script I've ended up with: http://pastebin.com/L366Z7xh
need to see the code a snipit of what you are talking about is hard to say
Added the code, the problematic area is inside of void Start
for future use you can paste code in here using the button it has a mouse over. ill see if I can find anything in the code
Answer by aldonaletto · May 31, 2013 at 01:30 AM
These rotations are the same: the 3-axes notation is redundant, and many XYZ combinations result in the same rotation. In this particular case, (180,270,180) results in the same rotation as (0,90,0) (5.0089e-06 is 0.000005, virtually zero).