I am making a race car and I just want to add a value on my variable “Lap” once the car triggered a gameobject which act as my finish line
Simply i just want to do this
var lap = 0;
function OnTriggerEnter(other :
Collider) { if(other.gameObject.tag ==
“Player”) { lap +1; } }
then afterward i want to use the said value (lap) to show on my GUI and if the value is equals to 3 show a “Complete Race” text on my GUI
I used
var lapCounter : GameObject;
function OnGUI () { var curLap =
lapCounter.GetComponent(“lapCounter”).lap;
GUI.Label (Rect
(Screen.width-100,50,120,20), “Lap:”
+curLap);
and
var playerlap = 1; private var
guiEnable = false;function OnGUI() { if (guiEnable) {
GUI.Label (Rect
(Screen.width/2,Screen.heigth,400,200),“RACE
COMPLETE”); } } function Update () {
if (playerlap == 3) { guiEnable =
true; } }
I don’t know what seems to be the problem…