|
Hi, I've already found some bits of code here but that still doesn't answer my question. I'm trying to create a day/night cycle. I have 4 colours for each day time. So morning, noon, dusk, night. They are stored in separate variables. I want the light colour to lerp from one to another in certain amount of time per colour. Can someone write a bit of code and hopefully describe WHY and WHAT'S happening? :) tl;dr I want to cycle between 4 light colours to create a day/night cycle. Also, how do I loop this behaviour?
(comments are locked)
|
|
Hello, here's my example. I do not use lerp here but if you need that you can substitute the Mathf.Sin with any functions you want. Some code might be redundant to you since I included some timing optimization. The light is updated every t you specify in UPDATE_INTERVAL. The rest should be straight forward. Hope it helps. Note: you might need more precise functions to map the sun colour on time. These were just OK for my purposes.
(comments are locked)
|
|
hm, still at work and can't actually test this right now to write it, but take a look at http://www.youtube.com/watch?v=zxIyZzieFqE this covers a day / night cycle setup, including time and looping. It's not actually blending colors but uses a moving sun/moon & blending skyboxes but hope that helps
(comments are locked)
|

You could look at Fade for a starting point, specifically the third Colors function. The only thing you'd have to add is a certain amount of time for each color.