weird rotate issue/help, I've fallen into crazy and I can't get up

----- RESOLVED -----

Alright, so I was messing around with a sort of day/night cycle.

The basic setup:
A terrain.
An empty game object set to 1000,-250,1000
A directional light as a child of the empty. Set to 1000, 3000, 1000 (though really, it’s 0, 3000, 0 since it’s a child of the empty. In other words, parent it, then drag the light straight up.)

Added a script to the empty to rotate it. causing the light (aka, the sun) to rotate, using the empty as its pivot point. Here, have a lame ascii art example :stuck_out_tongue:

S


o

Where S = Directional light, — = terrain and o = empty object.

After coding a bunch and noticing strangeness, I took a step back, and went with the very basic transform.rotate, taken right out of the manual

transform.Rotate(Time.deltaTime, 0, 0);

also tried setting the Space, with the same results.

So, as I watch in the Inspector, all is going good as my sun slowly rotates around the terrain.
watching the X value update from 0 on up. When it gets to 90, it stops (and really, hitting EXACTLY 90? pfft unlikely with Time.deltaTime). The object actually keeps rotating, but the value stops updating, but only for a few seconds. But in that time, the Y and Z values change from 0 to 180 (both of them). Then the X starts up again, except now, because the y and z have changed to 180, X is now counting down towards 0 (and it continues on into 350s, right on down, as I would expect).

I think I may be going crazy :face_with_spiral_eyes: after noticing that, I decided to take a step back even further. Set up a brand new scene with the only thing in the scene being a capsule with a script attached to it. No extra code, no extra objects. Nothing to interfere. Here is the content of the script attached to the “sunEmpty”:

function Update () {
	transform.Rotate(Time.deltaTime, 0, 0);
}

Same result. Anyone have any clue as to what is going on?

fwiw: 3.5.0f5

It’s just quaternions (used internally) being converted to euler angles (displayed in the inspector). Don’t worry about it; the angles displayed are still correct. You can read up on quaternions if you want to understand what’s going on behind the scenes.

–Eric

Thanks for the explanation! Was just reading up on Quats after I posted. Still, it seems strange. It swaps the y/z values in the inspector every time the X hits 90 and 270.

Thanks again. Been a long day and I’m glad to know I’m not (completely) losing it.

Cheers