I thought that the gameObject.Find would work but it apparently just keeps counting and each time a new object enters and never subtracts when one leaves… So I tried to keep track of each ball that left play and subtract it from the Tagged objects that had been created but it seems there are a bunch of bugs this way as it sometimes miscounts…
I basically tried it each way I could so I decided to come here and have you all enlighten me on my mistake.
void OnTriggerEnter( Collider other){
Ball Ball = other.GetComponent<Ball> ();
if (Ball) {
ballsDead++;
ballsLeft = GameObject.FindGameObjectsWithTag("ball").Length;
Debug.Log(ballsLeft-ballsDead);
if (ballsLeft-ballsDead <= 0){
Ball.Die ();
}
}
}