Unity 3D Timer Script

May 15 2011  Categorized Under: Internet Market  2 Comments

To use the script you need to use the GUIText Component.. Ill update this post soon for the steps on how to use this script. For the meantime, you can copy and paste the script . :) Hoooray!!

//time variables
static var startTime : float = 180.0;
var timer: GameObject;
var intTime;
function Start()
{
// Measuring 1 – 60
accelerationTimer = Time.time;
}

function Update()
{

if (startTime > 0 )
{
timeTaken = startTime -= Time.deltaTime;
}

//time
if (timeTaken <= 0.0)
{
Debug.Log (“game over stop time!”);
startTime = 60.0; //time to read the quest
Application.LoadLevel(“gameOvertiktak”); //new gme overtime here

}

timer.guiText.text = FormatTime (timeTaken);

}

function FormatTime (time)

{

intTime = time;
var minutes : int = Mathf.FloorToInt(intTime / 60);
//var minutes : int = intTime / 60;
var seconds : int = intTime % 60;
var fraction : int = time * 10;
fraction = fraction % 10;

timeText = minutes.ToString () + “:”;
timeText = timeText + seconds.ToString ();
timeText += “:” + fraction.ToString ();

return timeText;

}


Share This Post!

2 Responses

  1. BlogGirl Says:

    thanks for sharing kht na d ko gets ung codes. someday maiintndhan ko rn yan :)

    [Reply]

  2. ako Says:

    how to user the timer scripts??step by step? pls. sir

    [Reply]

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Copyright 2010 emilgraphics.info designed by emilgraphics
Home | About | Skills | Links | Designs | Contact
All vectors and images used in this site is copyrighted and designed by emiljaranilla.