just like the question… i have 10 separate particle system paired as a child of an empty gameobject. all is set to not play at awake. i want to find a way to play 3 random particle system on start of game. i been google my eye out but have no idea. i can turn 1 on with a click and that’s not even at random. so how do the system randomly pick out 3 to play?
any help is greatly appreciated.
Since you are using an array of GameObjects, I’m assuming you turned off your particle systems by disabling the game object, and that ‘Play on Awake’ is still enabled.
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour {
public ParticleSystem[] particles;
public int numOn = 3;
void Start() {
for (int i = 0; i < particles.Length - 1; i++) {
int j = Random.Range(i + 1, particles.Length - 1);
ParticleSystem t = particles[j];
particles[j] = particles*;*
_ particles = t;_
* }*
for (j = 0; j < numOn; j++ {
* particles[j].Play();*
}
* }*
}
This shuffles the array and then turns the first three entries on.