Day/Night Simulation

From GalaxyWiki
Jump to: navigation, search

This tutorial demonstrates how to create a day/night cycling map. StarCraft II maps do track a time of day, but the default map lighting will not shift to reflect this. This tutorial will demonstrate the most simple way to select alternate lighting as well as track day/night in a timer window. This design is based off of Blizzard's day/night in the WOL mission "Outbreak".


In order to make the map's lighting shift between day and night an appropriate lighting must be used for time of day lighting. This is accomplished with the trigger action "Environment - Set Time of Day Lighting".
With only the most basic dependencies there is only one type of lighting that can be used for this - Korhal TOD. Adding campaign data or other dependencies will provide more lighting. For example, the MeinhoffCampaignDay lighting (used in "Outbreak") is part of the WOL campaign data.
This the only action required for the appearance of day and night.

Environment - Change the light used for time of day lighting to Korhal TOD"

Tip: Trigger conditions can test another HH:MM:SS against the time of day (in 24-Hour format).

Tracking and Timing[edit]

Preset Type
Trigger Tree
Timer Up


In order to set the length of the day cycle, and track the remaining time in a window, a number of variables will have to be created.

  • The best way to keep track of whether it is day or night is to create a preset type that will be switched when the timer is up.
    • Create a new preset and add two preset values. e.g. Day, Night (See the example screenshot.)
  • A Day/Night variable: This is a variable of the day/night preset type from above
  • Number of Days (optional): Two integers to track the number of days and nights that have passed. (Days should probably start equal to 1 if you start with daytime.)
  • The Length of a Day: Will be the number of Game Time seconds in a day. This should be a (constant) real value. e.g. DAY_DURATION = 30.0 <Real (Constant)>
    • The default length of a day and night is 1,080 game seconds. A matching DAY_DURATION would be 540.
  • The Timer: To track the time remaining before nightfall (and vice versa) a variable of the Timer type is required.
  • The Timer Window: The window that display the timer. This is of the Timer Window type.
  • Also create two triggers to set things up and to reset the timer.

Once done, the variables and triggers should look like the screenshots to the right.



The startup trigger will need to accomplish a few things.

  • Set the time of day lighting (as described above). e.g. Environment - Change the light used for time of day lighting to Korhal TOD
  • Set the day length to your variable. The trigger needs the total "24 hour" length. So pass in the duration variable multiplied by two.
    • If the variable is meant to be the complete time then divide by two when the timer is set.
  • Set the time of day (preset variable) to day.
    • To start at night the actual time of day would need adjustment as well as the initial timer time.
  • Start the timer as a one-shot timer (for better control) that lasts for the length of just a day or a night.
    • Again, if the time of day is changed then the timer will have to scaled back. (Games start at 06:00:00 (dawn) by default.)
  • Create a timer window for the timer with a title such as "Day 1" Using the remaining time. (It should be made visible.)
  • Set the timer window variable to the last created window so that it can be controlled later.
  • Set the style, color, and time format for the window. (Optional)

Timer Up[edit]

If there is no need to track whether it is day or night then simply restarting the timer may be all that is needed here. (In which case it would be better to make it a repeating timer in the first trigger.)

  • Create an if/then/else to see if the time of day (preset variable) is day (or night) and use the else for the other state.
  • Set the time of day (preset variable) to the other state. (e.g. from day to night)
  • Add one to the number of days/nights. (If keeping track)
  • (Optional and Cool) Some lights (such as streetlamps) can be switched on and off by sending the actor message Signals "LightPowerUp" and "LightPowerDown", respectively. (See the example screenshot.)
  • (Optional) Display a message for players. e.g. "It is night."
  • (Optional) Change the timer window's title. e.g. "Night 2"
    • This can be done with string concatenation or text with search replacement.
  • Restart the timer
    • Days can be made longer or shorter than nights (and vice versa) by changing the "24 hour" length (and timer length) in this trigger.


An example is available. It has a very fast day/night cycle. Download