As a progression from the real-time day / night cycle I created previously, I wanted to simplify this down into a choice of the player, whether it be a key press or through an additional widget such as a slider.
I found a great tutorial on how to implement this through a key press of your choice, switching from day to night when you wish. The method I used also includes text which overlays the screen telling the player whether it is day or night.
The way in which it works is that I have set the sun directly above the scene and on the key press, this rotates 180 degrees on the y axis, changing the sky sphere with it.
There is an extra inclusion of a “night threshold” variable, which allows the creator to choose a point on the rotation it is considered to be night or day. Also, creating an event for each (“Become Day” and “Become Night”). These custom events allowed me to add options to when either of these events occurred, in this case, display text informing the player.
I had a problem where the sun was still casting shadows from below the horizon, when it should be night. To counter-act this, I included extra code which had the sun intensity at 2.75 when its was considered “day time”. Finally, setting the intensity to 0 when it was “night time”, which solved the problem.
I still however, want to add a secondary light source in the Moon. I wish to add this to the sky sphere, casting shadows and light equivalent to the sun, albeit with less intensity.