Wanna enjoy truly long summer days, or short, dark winters? Real Sun Path will bring its beauty!
• Introduction
Here’s a quick astronomy lesson! We all know how the days are longer in the summer, and shorter in the winter. This is because the Earth is tilted 23.4 degrees. As the Earth orbits the Sun, its tilt direction remains the same relative to the stars, but faces either away or toward the Sun during the course of the orbit, causing variations in the amount of sunlight different parts of the Earth receive.
The result is a gradual lengthening and shortening of days, with the most significant changes occurring during the solstices and equinoxes. Furthermore, the path and the angle the Sun rises varies with latitude.
The daylength variation becomes increasingly pronounced at higher latitudes, eventually making some parts of the year receive 24 hours of Sun and 24 hours of darkness, which amazingly is what this script allows you to do! Below is an illustration of how the daylength is different at different times of the year.
By default, Roblox’s latitude is essentially strictly set at the Equator, with the Sun rising/setting vertically, and with the default GeographicLatitude acting like an axial tilt setting, which does nothing to increase the variation of daylength.
Below is a rough sketch of how the Lighting service handles the Sun’s movement.
Real Sun Path is a script that calculates the Sun’s realistic position in the sky, based on the Time of Day, Day of Year, Latitude, and Axial Tilt. . It is calculated using known equations used in calculating the Sun’s position, and is expressed as (x, y, z) coordinates that would be obtained from :GetSunDirection()
, and then converted into ClockTime and GeographicLatitude values in the Lighting property.
Here’s a demo on how it works!
*Please note that the Sunrise colour visuals seen in the video and the thumbnail are produced by 3D Atmosphere, a script that complements Real Sun Path!
3D Atmosphere Script
• How to implement
Its very easy to implement! Just open the model, and drag the main script to Workspace and that’s it!
There are other extra features included in the package, such as a Game Clock GUI, along with a Sun graph that shows the time the Sun rises and sets, its elevation, azimuth, and twilight phase, and a day/night cycle script that is specialized for this script!
IMPORTANT: If you are going to use a day/night cycle script, adjust the time, or change the latitude, please use the ClockTime property under this script!
The script uses the lighting’s ClockTime and GeographicLatitude as coordinates and should not be used! That will defeat the purpose of this script!
• Properties
You may wonder what these properties do, but here is an explanation of what each property does:
-
Analemma
Sun’s figure-eight movement at a fixed TimeOfDay due to Earth’s elliptical orbit. (Refer to thumbnail) -
Axial Tilt
Determines how far north, or south the Sun will rise/set. Earth is 23.437 degrees. -
ClockTime
The time of day in the game, local solar time (Middle of ideal timezone) -
DayOfYear
The number of days from January 1st. Determines how long or short the days are.
Vernal Equinox: 79 → Equal daylength as night.
Summer Solstice: 171 → Longest day of the year.
Autumnal Equinox: 266 → Equal daylength as night.
Winter Solstice: 354 → Shortest day of the year. -
GeographicLatitude
The vertical location from Earth’s equator. Determines how extreme the daylength variation is, thought the year. Set 0 degrees for the Equator, 90 for the north pole, and -90 for the south pole.
Any latitude above 66.563 or below -66.563 will experience 24 hours of Sun, or 24 hours of night at parts of the year, assuming AxialTilt is set at 23.437. -
Refraction
Due to this phenomenon, the atmosphere may cause the Sun to set a few minutes later than the actual sunset. Thats why you may notice at the equinoxes, the daylength is actually 12 hours and 7 minutes, instead of a solid 12 hours.
KNOWN BUG: The Sun may jitter out of place during the Midnight Sun. If you’re at the poles, I suggest disabling this feature.
Extra Features
• Game Clock GUI
The game clock GUI provides you a clock that players can view in the game. To implement, you just drag it into StarterGui.
The time shown is based on ideal timezones, 24 even slices of the Earth that are 15 degrees latitude apart, therefore the time displayed will not always match the ClockTime property, especially when the DST setting is on, and advancing the display time by 1 hour.
You can manually offset the time, in hours, which is useful if your game takes place outside its ideal timezone such as Madrid, where it lies on the GMT timezone, but uses CET.
The GUI also features a Sun graph, along with information above it, for those who enjoy observing the Sun’s movement!
Below is the changing latitude, from -90 to 90 degrees, at Summer Solstice, at 10:00 AM, and Real Sun Path in action!
• Day/Night Cycle Script
Included is a specialized day/night cycle script, which is completely different from the ones you will find out there, or using the :SetMinutesAfterMidnight()
method, or changing the ClockTime in the Lighting service.
To reiterate, the script uses the lighting’s ClockTime and GeographicLatitude as COORDINATES and should not be used! That will defeat the purpose of this script!
This script instead changes the ClockTime value under the Real Sun Path script, which fires every change in the property. To set up, leave in Workspace!
There are three properties under the script.
-
AdvanceDayOfYear: Makes the day of the year change every 24 hours elapsed, which is how it should be! Set it to false if you want the game to be solstice, or a specific day forever!
-
Enabled: If true, the script will cycle through day and night as it should, and if not, it will disable the day/night cycle.
-
Speed: Sets the speed of the day/night cycle. Example: 60 means 60 seconds elapsed per REAL seconds, or 60x real time. A day per second would mean a value of 86,400, and an hour per second would mean a value of 3600.
If you have any questions, concerns, or feedback, feel free to share below!