So my game is a game where you have to put objects in containers. Once all the objects are in the containers. I want the timer to stop and pull up an end level GUI that shows the score, the time it took and the bonus… which gives you the final score. Problem is… I am not REALLY a programmer…
I was able to program the timer counter
Code:
var min : int;
var sec : int;
var fraction : int;
var timecount : float;
var starttime : float;
var timeCounter : GUIText;
function Start ()
{
starttime = Time.time;
}
function Update ()
{
timecount = Time.time - starttime;
min = (timecount/60f);
sec = (timecount % 60f);
fraction = ((timecount * 10) %10);
timeCounter.text = String.Format("{00:00}:{1:00}:{2:00}",min,sec,fraction);
}
and the score
Code:
//This keeps count of the score
static var playerScore : int;
// This variable is a string
var scorePrint;
//boolean that changes the ball's status
var IsInside : boolean;
//gets the game object from inspector
var Trigger : GameObject;
//This variable allows us to put a GUIText game object in the inspector
var Scorecount : GUIText;
function start()
{
IsInside =false ;
}
function OnTriggerEnter(other : Collider)
{
if (other.gameObject== Trigger && IsInside == false){
playerScore =playerScore+10;
IsInside = true;
}
else if (other.gameObject==Trigger && IsInside == true){
playerScore =playerScore-10;
IsInside = false;
}
}
function Update()
{
scorePrint = playerScore.ToString();
Scorecount.text = String.Format(scorePrint);
}
Now I want to stop the timer when the Scorecount.text hits 60
the script was put on each of the objects hitting the trigger…
sample of the game here…
http://rblumenschein.webs.com/demooftiltgame.htm
PLEASE someone… how should I write the stop time counter code and should I attach that to the timer code or should I create another code
AND how do I get GUI to actually pull up on the screen once the level is ended…
Edit :
The container are the blue circle things in the middle… I am going to have to make it more obvious, you are the second person who were not able to tell what the containers are… they look like part of the art…
Also there is no way to go above 60 since these are attached to the actual ball so the is no need to lock the score.
What I need is for the time counter to stop when all the balls are in the containers…
Oh and I don’t think a tag will work since I have two triggers reading two different balls the small ball are on top and the big balls are on bottom