I have a empty game object called Clock with this script attached, I want to try and add time when I collid into another game object.
var timer : float = 10.0; //Create varable Timer of type float
function Update ()
{
timer -= Time.deltaTime;//Varable time decrements from set value (10.0)
if(timer <= 0)//When timer = 0
{
timer = 0;
Application.LoadLevel(6);//loads the game over scene
}
}
function OnGUI ()
{
GameObject.Find("TimerText").GetComponent.<UI.Text>().text="Timer:" + timer.ToString("0");
}
My Second script is on the game object I want to collid with once I hit this it should update the timer but I cant figure out where Im going wrong
import UnityEngine.UI;
function OnTriggerEnter (info:Collider)//when trigger enters
{
var pickUpAudio : AudioSource = GetComponent.<AudioSource>();
pickUpAudio.Play ();
//Timer.timer +=10;/
transform.position = Vector3(0,-1000,0);
yield WaitForSeconds (1.5);
Destroy (gameObject);/
}