Adding a Day/Night Cycle to “All Aboard!” Makes it Feel More Alive

Wow, what a difference such a small detail can make! Watching a day/night cycle while your selling tickets, boarding passengers and upgrading things makes it feel so much more alive! I love how the shadows slowly sweep by while the passengers hang out on the platform waiting for the next train.

I’m getting pretty excited about this new game! I’m busting out a lot of updates this weekend like getting the saving/loading working properly, UI initialization, and some other small additions that aren’t quite done yet.

I used a pretty simple script for this that rotates the sun and moon directional lights around the x-axis. Using a number between 0 and 1 will update the ‘time of day’. When the game initializes, the two directional lights (sun and moon) are pointed in opposite directions. I set the ‘time of day’ for the sun to noon (0.5) and the moon to midnight (0), and based on how many ever seconds a ‘day’ is (in this case 720 seconds), the two lights rotate and produce the cycle! Also, I have the moon directional light with a little less intensity and tinted blue for a nice nighttime feel to it. Here is the script & writeup I started with, then tweaked to my needs.

*EDIT – Reddit user /u/pturecki pointed out that the moon should be more ‘static’, as it doesn’t have the exact same path through the sky as the sun. I’m going to look into updating that for a more realistic feel. Thanks for the suggestion!

This GIF shows the day/night cycle sped up a bunch for demo purposes. Both day and night are 6 minutes long, completing a 24-hour cycle.

"All Aboard!" Day/Night Cycle GIF
“All Aboard!” Day/Night Cycle GIF

Leave a Reply

Your email address will not be published. Required fields are marked *