- Home /
Destroy Enemies With Tag/Color/Name according a indicator.
► Hi! I asked 3 different question about this problem and i tried many way but i can not solved it. Now. I have 7 different color object. And i used 7 object in indicator(in left green object). This objects are random spawned. And 7 another objects are spawn like enemies. How can i destroy enemies, according to indicator?
Unless you can specify the exact problem you're having, this post is way too vague. :-\
I think i exact my problem specify. Please read again. I need solved it.
Are you trying to spawn things on the colored blocks based on the indicator color? Green blocks will spawn things when the large left block is also green?
So all the same colour objects should destroy at once? I.e. Since Indicator is green, and none of other elements are green, thus no destroyed. If indicator was red, 3 cubes would have been destroyed?
Yes by mouse click. if indicator was red, red cubes would be destroy. One by one.
One by one means you would have to click the mouse 3 times to destroy three red cubes? And the click can be anywhere on the screen?
Do you have anything in place to manage those colors? $$anonymous$$aybe some enum or something as a public property on a common component?
No. I not use this. Look. if i used One object and one indicator i can use this code lane :
if(sign.gameObject.tag==enemies.gameObjec.tag) { Destroy(gameObject) } but this code not work for multiple objects. How can i do this ?
FindGameObjectsWithTag? This is the first google result. :-\
GameObject[] things = GameObject.FindGameObjectsWithTag(sign.gameObject.tag);
for (int k=0; k < things.Length; k++) {
if (things[k] != sign.gameObject)
GameObject.Destroy(things[k]);
}
Your answer
Follow this Question
Related Questions
find and destroy Multpile GameObject[] tag. 2 Answers
How can i destroy multiple objects with tag? 2 Answers
How to use tag for all players in the Instantiate. 0 Answers
Object Pickup and Respawn unity 0 Answers