Hello, I have a gameobject that if a if statement applies to my script a object will Instantiate, but when i run the game it instantiates way to many and does not stop making the object what am i doing wrong. Here is my code. BTW i want to keep the way its setup but just only have it Instantiate the model one time.
public Transform Weapon1GO;
public string Weapon1;
public GameObject Tac50;
public Transform WeaponSpawn;
void update(){
Weapon1 = “Tac50”;
WeaponSpawn = transform.Find(“Main Camera/WeaponWalkHolder/WeaponJumpHolder/WeaponSwayHolder/WeaponRecoilHolder”);
if(Weapon1 == “Tac50”){
if(Weapon1GO == null){
GameObject weapon1I = Instantiate(Tac50, transform.position,transform.rotation) as GameObject;
weapon1I.transform.parent = WeaponSpawn;
}
}
}
Update I know why this is happening but i dont know how to stop the instantiating, ive tried bools. Please some one tell me how to fix this.
Please format your code. If you do not know how, watch the tutorial video and look at the FAQ: http://video.unity3d.com/video/7720450/tutorials-using-unity-answers http://answers.unity3d.com/page/faq.html
– Benproductions1