I have searched and found no answers that work for what I’m trying to do. So now I really need help.
I want to make a day and night cycle in my game. For this I want the sun to move certain degrees during different timesets of the day. For example during sunrise the sun should move 60 degrees, and during day it should move 120 degrees. And I want the sun to do this during the time spent in each section so when I reach the next time set (for example from sunrise to day)it should have reached the final degrees.
So if my sunrise is 10 seconds I want the sun to move 60 degrees in 10 seconds. And when I reach 10 seconds my timeset will turn into day and then I want the sun to move 120 degrees in 20 seconds. So the sun always moves, and it moves the amount of degrees it should during each timeset. However I have not been able to do this.
This is the last function of like a million I tried without luck.
IEnumerator RotateSun(Vector3 fDegrees, float SecondsDuringTimeSet)
{
//lSunLight.transform.eulerAngles = new Vector3(fDegrees, 0, 0);
Quaternion quaFromPosition = lSunLight.transform.rotation;
Quaternion quaToPostion = Quaternion.Euler(lSunLight.transform.eulerAngles + fDegrees);
for (float t = 0.0f; t < 1; t += Time.deltaTime / SecondsDuringTimeSet)
{
lSunLight.transform.rotation = Quaternion.Lerp(quaFromPosition, quaToPostion, t);
yield return null;
}
}
Could someone please help me with this? I’ve been stuck forever with this now.