So right now its about 12:30 at night.
And im tired.
And i have this !simple script to achive a simple day/night affect.
Here’s my code:
var hour = 5;
light.intensity = 0;
function Update () {
transform.Rotate(hour*Time.deltaTime, 0, 0);
if (transform.localRotation.x >= 200)
light.intensity = 0;
else
light.intensity = 1;
}
It never goes dark.
Never.
When I pause the game when it should be dark and check the Xrotation. Its always above 200.
Please help. I’ve been trying to figure this out for 20 minutes, and im ready to chuck a small animal out of a window. With NO parachute. Heheheheheeeee…
I need sleep.
Transform.localRotation stores Quaternions. What you want is Transform.eulerAngles.
Try checking out BurgZergArcade’s tutorials.
As DreamBlur said,you should use transform.eulerAngles.It uses degrees (from 0 to 360).So you gotta increase these angles based on your hour.So if the hour = 23:59 angles = 359;
if the hour = 00:01 angles = 0;
Again,as DreamBlur said,transform.localRotation stores Quaternions,so numbers from -1 to 1.
You would have to convert hour * Time.deltaTime to a value that goes from -1 to 1,which would be very complicated or impossible.
- I would just link the rotation of the sun to the hour.So it would be something like :
transform.eulerAngles = Vector3(hour/24 * 360,0,0);
And the hour must be increasing like hour += 5 * Time.deltaTime
-This way,if you go and instantly set the hour to 18,the sun imediatly changes rotation.
You can also try Quaternion.Euler,i guess.
Good luck! 
Thank you guys SO much. You guys are lifesavers. (and not the candy)