I have a JavaScript and i want to add a counter to my game. I have a script added to my Character but it doesn’t count the score.
How do I do fix this?
JavaScript:
var score = 0;
var scoreText = "Score: 0";
var mySkin : GUISkin;
function OnTriggerEnter( other : Collider ) {
Debug.Log("OnTriggerEnter() was called");
if (other.tag == "point") {
Debug.Log("Other object is a point");
score += 1;
scoreText = "Score: " + score;
Debug.Log("Score is now " + score);
Destroy(other.gameObject);
}
}
Counter:
var MenuSkin : GUISkin;
var toggleTxt : boolean;
var toolbarInt : int = 0;
function OnGUI() {
GUI.skin = MenuSkin;
GUI.BeginGroup(new Rect(Screen.width/2-150,Screen.height/100-0,250,50));
GUI.Box(Rect(0,0,250,50),"Score: ");
GUI.EndGroup ();
}