Unity
Unity Time Script
Introduction
Here's a script that i have been working on in unity, It controls the Sun and Tracks the time that your game has been open for.
Features
*Tracks Time 1 sec = 1 min and so on.
*Realistic Sunrise and sunset animations
*Customization sunset and sunrise colors
*Rotates the sun accordingly
*Highly customizable with hourly events
*Extensively commented for readers ease.
Screenshots
The Code
License Terms
Attribution 3.0 Unported - You must attribute the work in the manner specified by the author or licensor. Commerical use allowed.
Instructions
Copy and paste this into your assets folder of you game.
Then create a directional light as your sun, Attach this script to the directional light and your done!
Author Notes
This script is not complete, Although features are, I will continue to update this until if finish it, as i will be using this script in my own game.
If you find a bug please report it to me so i can put it on the things to fix list
Version History
Initial creation v1.0 Added the ability to count one min per sec
// v1.1 added variables and presets for seasons days and months, roation speed can be set
// v1.2 revised the code that controls the rotation of the sun, MATHS FTW
// v1.3 created hour check that allows events to happen on the hour, sunset create
// v1.3 sunset and sunrise created, code now uses invoke repeating to control time
// v1.4 revised the hour check code and added time speed variable to allow for 10x the normal speed.
// v1.5 revised the sunset code adding the abbility to change the amount of time sunrise and sunset take
// also adding the effect of the sun rising and setting below the horison, colors are editable
// v1.6 revised the sunset code again adding the skybox dimming and fog color to further increase the
// realism of a sunset and sun rise.
// v1.7 some extra code clean up and commenting. This code alone should be able to control every object in the game.
// v1.7.5 Added Simple GUI Buttons and toggle Fixed a few more bugs with time updating.
// Planned v1.8 add physical sun and make it rotate to the sun direction
// Planned v1.9 make phsical sun change colors on sunset ect.
// Planned v2.0 Recode to add events for each hour, Intergrate with weather code
Credits & Thanks
Me?
Comments (0)
Leave a Reply
You must be logged in to post a comment.
Polraudio
You can actually remove #pragma strict if you want. doesnt make a difference. mainly used for debugging from my understanding. Nice script, nice to see more people trying out unity.