In this lesson, you will learn how to chain Particle Systems together using the Sub-Emitters module to trigger secondary visual effects at specific points in a particle's lifecycle.
Understanding Sub-Emitters
Up until now, you have managed particles as individual entities. However, complex effects—like a firework that explodes into smaller sparks or a projectile that leaves a lingering trail of smoke—require multiple, interdependent systems. A Sub-Emitter allows a "Parent" system to spawn a "Child" system based on specific lifecycle triggers rather than relying on a separate script or constant emission.
Triggering Lifecycle Events
The Sub-Emitters module, found within the Particle System inspector, allows you to designate a system to spawn whenever a particle meets one of these criteria:
- Birth: Spawns a child immediately when the parent particle is created.
- Collision: Spawns a child exactly where a parent particle hits an object (perfect for impact sparks).
- Death: Spawns a child the moment a particle expires (ideal for smoke puffs at the end of a trajectory).
Practical Application: Impact Sparks
To create an impact effect, you don't need complex logic. You simply create your main "Projectile" system, then add a second Particle System object in your scene hierarchy specifically for "Sparks." In the Projectile’s Sub-Emitters module, drag your Spark system into the slot and set the trigger to Collision.
When the Projectile hits a collider, the engine automatically inherits the transform of the parent particle and emits the child system at that precise coordinate.
// You don't need code to trigger the sub-emitter,
// but you can control it via the ParticleSystem component:
var subEmitters = myParticleSystem.subEmitters;
subEmitters.enabled = true;
subEmitters.AddSubEmitter(mySparkSystem, ParticleSystemSubEmitterType.Collision, ParticleSystemSubEmitterProperties.Inherit);
By nesting these systems, you offload the complexity of position tracking to the engine's internal loop. This not only keeps your particle logic modular but also significantly improves performance by allowing the particle system to manage its own hierarchy without needing Update() calls from your own scripts.
Key Takeaway: Use Sub-Emitters to decouple complex visual effects, allowing child particle systems to inherit the position and lifecycle state of a parent particle automatically.