I made a script that makes the time of day change gradually at a certain speed, but I can’t get the sky color to change the right way. The variable “sky” in this script is the same material that the skybox is. The color of the sky is supposed to gradually change color and not change immediately. This is the script:
var speed : float = 0.5;
var stars : GameObject;
var day = Color(.302, .404, .808, 1);
var night = Color.black;
private var sunset : boolean;
var mid = Color.red;
var sky : Material;
var curSky : Color;
var smooth : float;
function Update() {
transform.Rotate(speed*Time.deltaTime,0,0);
if(transform.rotation.eulerAngles.x < 30){
if(sunset == true){
curSky = Color.Lerp(day, mid, Time.deltaTime * smooth);
}
if(sunset == false){
curSky = Color.Lerp(night, mid, Time.deltaTime * smooth);
}
}
if(transform.rotation.eulerAngles.x > 30){
if(transform.rotation.eulerAngles.x < 90){
sunset = true;
curSky = Color.Lerp(mid, day, Time.deltaTime * smooth);
}
}
if(transform.rotation.eulerAngles.x > 90){
sunset = false;
curSky = Color.Lerp(mid, night, Time.deltaTime * smooth);
}
sky.color = curSky;
}