Hi to all,
I got a gameObj wich contains a particle system (a looping 2" explosion). I make this gameObj active at a specific time of an animation clip… BUT sometimes happens that the explosion became visible on an “intermediate moment” instead of the “start moment” of its loop.
What i’m trying to do is to “reset/estart” the particle emitter when it became visible…any idea?
if(myAnimation"].time>MyActivationTime){
particleObj.active = true;
//HERE I NEED PARTICLE RESET!
}
Thanks!
I’d suggest making the explosion a separate prefab that you instantiate at the right moment, as this would be simpler and more flexible.
Failing that, you may be able to reset it by setting the particles property to an empty array. You could also leave the emitter turned off and manually call the Emit function to emit some particles on demand.
Or, you could just call particleEmitter.ClearParticles()…
Hah! Good point, I forgot that was there! 
I’d still do it with a prefab, though.
Does anyone know if it makes any sense (doing iphone optimization here) to create a pool of particle explosions upon loading the game? I know it has been a big help to use object pools for things like enemies and bullets…but does it make sense with particle systems? It’s been a challenge to get the particles to emit and reset properly when the explosions are called from a pool of particle explosions that never get destroyed.
I wouldn’t make a pool of particle systems for that. Instead, I’d make a particle system for each kind of particle and share it between everything that needs that kind of particle.
For example, you might write a function that calls Emit(position, velocity, size, energy, color) a number of times to output particles from a particular position and with settings that make them look like an explosion. Having done that, you can call your custom CreateExplosion(position) function whenever you want to make a new explosion appear from the same particle system.
This way, you benefit from fewer draw calls as well as having less individual objects to create and destroy. However, if any part of the particle system is visible, the entire system must be drawn, which may result in more particles being drawn than would otherwise have been the case. This might not be an issue in practice, but you might want to do some tests to see if it makes a difference for your situation. If all the particles would have been onscreen in any case, there’s no difference.