Question by
Altazur · Mar 05, 2016 at 12:39 PM ·
particlesystemarray of gameobjects
Turning on the particles group at once
Hi, Unity community! Here the problem: i have two group of the gameobjects with the children object with the particle system attached. I want to turn them on\off at once due to some game condidtions. My code (c#)
public void PenetrateEffect(bool White)
{
int i;
if (!White)
{
GameObject[] EffectsB = GameObject.FindGameObjectsWithTag("effect_b");
for (i = 0; i < EffectsB.Length; i++)
{
EffectsB[i].GetComponent<ParticleSystem>().Play();
}
}
else if (White)
{
GameObject[] EffectsW = GameObject.FindGameObjectsWithTag("effect_w");
for (i = 0; i < EffectsW.Length; i++)
{
EffectsW[i].GetComponent<ParticleSystem>().Play();
}
}
}
As you see, i used to create the array of the GameObjects based on the tags. And then i simply use the PLay() method for every element of array. It's cause the next: after the event happens only two of eight emitter start to emit particles. I don't understand where i made a mistake.
Comment
Your answer