I have added collectibles into the game that I am making and created a script to show the amount of collectibles left to collect, however it shows how many there are when the scene starts but does not update when they have been collected. The code for collecting is:
function OnTriggerEnter(Collection : Collider){
if(Collection.gameObject.name == "Character"){
Debug.Log("Collected");
Destroy(gameObject);
}
}
and the code to create the GUI is:
var collect : GameObject[];
collect = GameObject.FindGameObjectsWithTag("Collectible");
function OnGUI(){
GUI.Label (Rect (10, 10, 100, 20),"Collected: " + collect.length);
}
Can anyone tell me how to get the GUI to update when the objects have been collected?