I want to make sunset effect, so my dir.light should change color from yellow to red. well here is a code:
function dayTime(){
if(transform.localRotation.eulerAngles.y < 237){
isDay = true;
}
if(transform.localRotation.eulerAngles.y < 57){
isDay = false;
}
if(isDay){
sun.color = Color.Lerp(dawnLight,dayLight,Time.time/4);
if(sun.intensity<0.6){
sun.intensity += 0.001;
moon01.intensity -= 0.001;
}
}else{
sun.color = Color.Lerp(dayLight,dawnLight,Time.deltaTime/4);
if(sun.intensity>0.0){
sun.intensity -= 0.001;
moon01.intensity += 0.001;
}
}
}
function Update(){
if(squadScript.go){
transform.Rotate(Vector3.up * Time.deltaTime*10);
dayTime();
}
}
Well issue is that, “Color.Lerp” worked only once during run.