I have the fallowing script attached to my charactor it is designed so that I can collect eggs and show the amount on the screen of how many I have picked up. The script works good but what im wanting is to place a empty game object near my wagon where the eggs are going to be droped that reads how many eggs have been collected and when the number is lets say 20 and I collide with that spot it loads the next level. Im not shure how to get it so that it can read the number of eggs i have got and determin weather to load next level.
var eggDisplay : GUIText;
var egg = 0;
var eggsToWin = 20;
function Start() {
DisplayAmount();
}
function DisplayAmount () {
eggDisplay.text = ""+ egg + " eggs";
}
function OnTriggerEnter(other : Collider) {
if (other.CompareTag("egg")) {
egg++;
DisplayAmount();
Destroy(other.gameObject);
}
} `