- Home /
In game clock/Time
Hey guys, I am thinking of adding an In-Game-Clock to my game but do not know how. what I am looking to achieve is this:
But located on the players screen like a Game HUD.
And I want it to be able to change game time e.g 1 min later clock changes... it may be complex but all help would be grateful!
Thank you -Izzy
Answer by Griffo · Sep 04, 2012 at 08:05 PM
Create an empty game object, put a GUI Text on it and choose the font you want, If you don't have that font download it from
http://www.1001freefonts.com/3d-fonts.php
Then add the below script, you will need to edit it to your requirements, the below will print the hours minutes and seconds on screen, you can add the day, month and year, plus position it where you want, hope that helps you out.
#pragma strict
private var dt = Date();
function Update () {
var day = dt.Now.Day;
var month = dt.Now.Month;
var year = dt.Now.Year;
var hours = dt.Now.Hour;
var minutes = dt.Now.Minute;
var seconds = dt.Now.Second;
guiText.text = hours + " " + minutes + " " + seconds;
}
Thank you man! I have edited the script for now so I can just have the Hours & $$anonymous$$ins :D
private var dt = Date();
function Update () {
var day = dt.Now.Day; var month = dt.Now.$$anonymous$$onth; var year = dt.Now.Year; var hours = dt.Now.Hour; var $$anonymous$$utes = dt.Now.$$anonymous$$inute; //var seconds = dt.Now.Second;
guiText.text = hours + ":" + $$anonymous$$utes; //+ "" + seconds;
}
Thanks again :D
Your answer
Follow this Question
Related Questions
Accelerate/Decelerate Custom Game Clock 2 Answers
Changing lighting/skybox based on Computer Time? 1 Answer
putting the date into a variable 1 Answer
Accurate millisecond timed thread 2 Answers
Clock Trigger 2 Answers