Created
September 27, 2013 18:03
-
-
Save keiranlovett/6732564 to your computer and use it in GitHub Desktop.
GameTime rotates a directional light to match the appropriate direction of the sun for the system time of day.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import System; | |
var date = DateTime.Now; | |
var timeDisplay : GUIText; | |
function Start() { | |
InvokeRepeating("Increment", 1.0, 1.0); | |
} | |
function Update () { | |
var seconds : float = date.TimeOfDay.Ticks / 10000000; | |
transform.rotation = Quaternion.LookRotation(Vector3.up); | |
transform.rotation *= Quaternion.AngleAxis(seconds/86400*360,Vector3.down); | |
if (timeDisplay) timeDisplay.text = date.ToString("f"); | |
} | |
function Increment() { | |
date += TimeSpan(0,0,0, 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment