Hello Everyone,
I’m trying to make a multiple OnTriggerEnter for a race. There is the starting point that triggers a timer when the player enter it and it stops when the player enter the end trigger.
Unity tells me I have syntax errors, but I don’t understand where … Can you help please ?
Thanks in advance
my script :
var finished : boolean = false;
var winningPicture:Texture;
var timer:UnityEngine.UI.Text;
var raceTime:float=0.0;
function OnTriggerEnter(col: Collider)
{
if (col.name == "EndTrigger")
{
Debug.Log("Congratulation !");
finished = true;
}
function OnGUI()
{
if (finished)
{
GUI.Label (Rect(Screen.width/2 - 232, Screen.height/2 - 50, 464, 100), winningPicture);
if (GUI.Button (Rect (10,50,300,40),"Restart Game"))
{
Debug.Log ("Restart button was pressed");
Application.LoadLevel ("La peur du vide_scene");
}
}
}
function Update()
{
if (!finished)
raceTime = raceTime+1*Time.deltaTime;
timer.text = raceTime.ToString("f2");
}
else if (col.name == "StartTrigger")
function Update()
{
raceTime = raceTime+1*Time.deltaTime;
}
}