I am trying to get a UI counter to work off a global variable since there are several items that will be connected to this script.
I need it to add one to the counter every time one of the items is destroyed.
So far my UI script looks like this (it is very messy, I know)
static var Counter : int = 0;
guiText.text = " " +Counter;
and this is the code for thr items so that they get destroyed and my attempt to add a global variable to it.
static var Counter : int = 0;
function OnTriggerEnter (){
Counter = Counter + 1 ;
Destroy(gameObject); //Destroys the object the script is attached to.
}
what do I need to do to make this work