Answer the question
In order to leave comments, you need to log in
How to destroy multiple objects at once?
During a collision with a bonus, the player must destroy all enemies at once, through findGOwithTag only 1 object is destroyed, and a maximum of 4 is needed
Answer the question
In order to leave comments, you need to log in
var objs = GameObject.FindGameObjectsWithTag( "X" ); // возвращает МАССИВ!
for( int i = 0; i < objs.Length; i++ )
Destroy( objs[ i ] );
I repeated the option from Vladimir Yurchenkov , but in a slightly different style:
foreach(var obj in GameObject.FindGameObjectsWithTag("x").Take(4)) //Take ограничит последовательность четырьмя элементами
Destroy(obj);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question