So in my game if a player matches two objects he gets a score,and some more stuff gets instantiated. i am using the update function to check for a match and instantiate stuff but loads of things just keep instantiating.I need help code below
#pragma strict
var noOfClicks:int;
var yes:int;
function Start () {
}
function Update () {
if (yes==2){
yes=0;
GameObject.Find("caller").SendMessage("First");
GameObject.FindWithTag("model").SendMessage("Correct");
GameObject.Find("count").SendMessage("Counter");
GameObject.Find("manager").SendMessage("Call",1);
Destroy();
}
if(noOfClicks==2&&yes<2){
noOfClicks=0;
GameObject.FindWithTag("model").SendMessage("Wrong");
GameObject.Find("caller").SendMessage("First");
GameObject.Find("manager").SendMessage("Call",1);
Destroy();
}
}
function Destroy(){
Destroy(gameObject,1.0);
}
function ClickCounter(){
noOfClicks++;
}
function ScoreCounter(){
yes++;
}