- Home /
This question was
closed Oct 04, 2018 at 08:35 AM by
$$anonymous$$ for the following reason:
I Found The Answer...TNX TO ALL
Question by
$$anonymous$$ · Oct 04, 2018 at 06:43 AM ·
taggameobjectsforeachfindgameobjectswithtagsingle
How To Select Single Object From All Objects We Found Whit Tag?
So I'm create the code who find and delete every game object whit specific tag...
// This code destroy all of Game objects whit "Cube" tag even if you put this 3 line in start //////////////////////////////////////////////////////////////////////////////////////////////////////////////// foreach (GameObject Cubes in GameObject.FindGameObjectsWithTag("Cube")) { Destroy(Cubes);
}
How can I change the code to just destroy one of the founded game objects?
Comment
Answer by Dankey_Kang · Oct 04, 2018 at 08:17 AM
If you want to destroy one active game object with the tag "Cube", you can do this.
GameObject cube = GameObject.FindWithTag("Cube");
If (cube != null) {
Destroy(cube);
}