MilKID – Dynamic Season/Weather Changer

Stuff I did.

My goal for this was to create a weather system that takes the seasons into account. To achieve a realistic solution I wrote a script that needs the length of the year in hours, which it will then use to calculate the length of each day. There is a timer that counts the days that have passed to evaluate the current day of the year and which season we are currently in. Depending on the current season, the user can input values for the probabilities of sunny weather, rainy weather, foggy weather and snowy weather. The script will randomize the duration for each weather type between a set minimum and maximum amount. It will also randomize the current temperature.

How it works:

The DateManager script evaluates the length of each day depending on the input length of the year and keeps track of the current day of the year.  While the SeasonManager uses the current day to evaluate in which season we are currently in. The length of each season is evaluated by the real world values for the northern hemisphere. The SeasonManager also carried all the variable for the weather probabilities and min/max temperatures for each season. The WeatherManager takes care of changing the weather using a state machine. The duration of each weather period is randomly generated between a set minimum and maximum value. You’ll also have to determine light intensity for each weather type, fog density, and colour for foggy weather and the particle systems for each weather type.


To Set it up you have to create an empty game object which will hold the SeasonManager
and the weather manager – they can both be on the same GameObject. I usually create
another empty game object for the DateManager and have this one as the child of the
Season and Weather Manager game object.
Now you have to set all the values in the Inspector.

powered by Typeform