Sub Emitters
Starting from Babylon.js v3.2, you can create sub emitters which let you spawn a new particle from an existing particle. Each one of these spawned sub particle systems is totally independent from the parent.
Note: Sub emitters are NOT supported in GPU particles.
How To Use Sub Emitters
The list of sub particle systems to be used as sub emitters is kept in an array and assigned top the new property subEmitters
of the appropriate system.
// Create sub emittervar subEmitter = new BABYLON.SubEmitter(subParticleSystem);// Have the sub emitter spawn the particle system when the particle diessubEmitter.type = BABYLON.SubEmitterType.END;// Set the +Y direction of the sub emitter equal to the direction the particle is/was headingsubEmitter.inheritDirection = true;// How much of the existing particles speed should be added to the emitter particlessubEmitter.inheritedVelocityAmount = 1;
particleSystem.subEmitters = [subEmitter];
Specifying an array of arrays of sub emitters will choose a random array and all the sub emitters in the chose array will be attached to the spawned particle.
particleSystem.subEmitters = [[subEmitter],[subEmitter, subEmitter2, subEmitter3], [subEmitter4]];
END sub emitter type
When a particle dies one of the particle systems in the array is selected at random as the one to be spawned. It is then cloned and rendered. Any element of the array can itself have subEmitters
and hence a chain of sub emitters can be formed. In this case the property manualEmitCount
could be used to avoid an infinite loop of creating and spawning new systems.
ATTACHED sub emitter type
When a particle is spawned this emitter will be cloned and attached to the new particle. This can be used to create a trailing particle effect on new particles.
To support attached sub emitter's to have their orientation accounted for when emitting particles, their emitter must be a mesh type:
subEmitter.particleSystem.emitter = new BABYLON.Mesh("", scene);
Active Sub Systems
Each particle system with that has sub emitters also has a property activeSubSystems
which is an array containing all currently active sub particle systems.
You can stop the root ParticleSystem
and all activeSubSystems
by calling the stop function on the root system:
particleSystem.stop();
When you want to stop the root system without affecting the activeSubSystems
, you pass false to the Stop function:
particleSystem.stop(false);
Demos
Sub Emitters Sub Emitters On Death Only Complete example (hit Space to launch a barrel)Further reading
Particle System
Learn all about the particle system in Babylon.js.

Particles
Dive into the rich and exciting world of particles in Babylon.js.

Animating Particles
Learn how to animate particles in Babylon.js.

Solid Particle System
Learn all about the solid particle system in Babylon.js.

Customizing Particles
Learn how to customize particles in Babylon.js.
