- Home /
delete object on start c#
Hi everybody I'm trying to add a gamemode to my game, survival in survival there is a triger box to spawn AI (working) now, I wan't to delete the triger box when the gamemode is not survival so far i have this:
public GameObject AIspawn;
...//more codes
void Awake () {
gameNumber = (string)PhotonNetwork.room.customProperties["gameNumber"];
if(gameNumber == "THREE"){
//not this so I leave it blank
}else
{
DestroyImmediate(AIspawn,true);
}
//more codes
This is not working, the AI triger box never exists (but it works if i don't have this code, unfortunaly, in all gamemodes)
Anybody know what I should do?
Answer by The Kracken · Dec 02, 2013 at 09:28 PM
Assuming you are attaching this script to the object where you spawn AI, Just use Destroy(this.gameObject); or if you just want to remove that script use Destroy(this);
Your answer
Follow this Question
Related Questions
Cinema 4D Deformer Export 1 Answer
Help with coding a simple grapple system - javascript 1 Answer
Faux Gravity Jumping 1 Answer
Help platform rotating on x-Axis passes through colliders 0 Answers