- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
el-santia93 · Sep 20, 2013 at 05:30 PM ·
instantiateupdate
Hi,Please i need help comparing conditions in the Update Function
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++;
}
Comment
Answer by jheiling · Sep 20, 2013 at 06:42 PM
You have a delay of 1 sec before your GameObject gets destroyed. In the meantime your Update method gets called every frame and instantiates stuff.