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 spawned sub-particle system is totally independent of the parent.
Note: Sub emitters are not supported in GPU particles.
How To Use Sub Emitters
The list of sub-particle systems used as sub emitters is kept in an array and assigned to the subEmitters property of the appropriate system.
import { SubEmitter, SubEmitterType } from "@babylonjs/core/Particles/subEmitter";// Create sub emittervar subEmitter = new SubEmitter(subParticleSystem);// Have the sub emitter spawn the particle system when the particle diessubEmitter.type = 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];If you specify an array of arrays of sub emitters, a random array will be chosen, and all the sub emitters in that 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 make attached sub emitters respect orientation when emitting particles, their emitter must be a mesh type:
import { Mesh } from "@babylonjs/core/Meshes/mesh";subEmitter.particleSystem.emitter = new Mesh("", scene);Active Sub Systems
Each particle system 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.
