Sub-emitters let you create extra particle effects that start when main particles die or collide. This helps make effects look more natural and exciting.
Sub-emitters in Unity
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
Unity
ParticleSystem subEmitter = mainParticleSystem.subEmitters.AddSubEmitter(subEmitterPrefab, SubEmitterType.Birth, SubEmitterProperties.InheritColor);
Use
SubEmitterType to decide when the sub-emitter triggers: on Birth, Collision, or Death of the main particle.Sub-emitters are added to the main particle system's
subEmitters property.Examples
Unity
mainParticleSystem.subEmitters.AddSubEmitter(smokePrefab, SubEmitterType.Death, SubEmitterProperties.None);Unity
mainParticleSystem.subEmitters.AddSubEmitter(sparkPrefab, SubEmitterType.Collision, SubEmitterProperties.InheritColor);
Unity
mainParticleSystem.subEmitters.AddSubEmitter(flashPrefab, SubEmitterType.Birth, SubEmitterProperties.InheritLifetime);
Sample Program
This script adds a sub-emitter to the main particle system. The sub-emitter plays its effect whenever a main particle dies, such as smoke or sparks. It then starts the main particle system.
Unity
using UnityEngine; public class SubEmitterExample : MonoBehaviour { public ParticleSystem mainParticleSystem; public ParticleSystem subEmitterPrefab; void Start() { // Add a sub-emitter that triggers when main particles die mainParticleSystem.subEmitters.AddSubEmitter(subEmitterPrefab, SubEmitterType.Death, SubEmitterProperties.None); // Start the main particle system mainParticleSystem.Play(); } }
Important Notes
Sub-emitters only work if the main particle system has subEmitters enabled.
Remember to assign the sub-emitter prefab in the Unity Editor or by script before adding it.
Sub-emitters can affect performance if overused, so use them wisely.
Summary
Sub-emitters create extra particle effects triggered by main particles.
They can start on particle birth, collision, or death.
Use them to make effects more dynamic and realistic.
Practice
1. What is the main purpose of
sub-emitters in Unity's particle system?easy
Solution
Step 1: Understand sub-emitters role
Sub-emitters are used to add extra effects that happen when main particles do something.Step 2: Identify correct purpose
They trigger new particles on events like birth, death, or collision of main particles.Final Answer:
To create extra particle effects triggered by main particles -> Option DQuick Check:
Sub-emitters = extra triggered effects [OK]
Hint: Sub-emitters add effects triggered by main particles [OK]
Common Mistakes:
- Thinking sub-emitters control particle speed
- Confusing sub-emitters with color changes
- Assuming sub-emitters pause emission
2. Which of the following is the correct way to add a sub-emitter in Unity's Particle System component?
easy
Solution
Step 1: Locate sub-emitter settings
In Unity's Particle System inspector, there is a Sub Emitters section to manage sub-emitters.Step 2: Add sub-emitter correctly
You add a sub-emitter by clicking the '+' button inside that section to assign a particle system as sub-emitter.Final Answer:
In the Particle System inspector, expand Sub Emitters and click '+' to add a sub-emitter -> Option AQuick Check:
Sub Emitters panel '+' button = add sub-emitter [OK]
Hint: Use '+' in Sub Emitters section to add sub-emitters [OK]
Common Mistakes:
- Adding a separate Particle System component instead
- Trying to link particles via Animator window
- Spawning particles only by script without sub-emitters
3. Consider a particle system with a sub-emitter set to trigger on particle death. What happens when a main particle dies?
medium
Solution
Step 1: Understand sub-emitter trigger types
Sub-emitters can trigger on birth, death, or collision of main particles.Step 2: Effect of death trigger
When a main particle dies, the sub-emitter spawns its own particles at that exact position.Final Answer:
The sub-emitter spawns its particles at the main particle's death position -> Option CQuick Check:
Death trigger = spawn sub-particles at death spot [OK]
Hint: Death trigger spawns sub-particles at main particle's position [OK]
Common Mistakes:
- Thinking sub-emitters stop main emission
- Believing sub-emitters change main particle color
- Assuming sub-emitters only trigger on birth
4. You set up a sub-emitter to trigger on collision, but no sub-particles appear when main particles collide. What is the most likely cause?
medium
Solution
Step 1: Check collision module status
For sub-emitters to trigger on collision, the main particle system must have collision enabled.Step 2: Identify cause of no sub-particles
If collision is off, no collision events happen, so sub-emitters won't trigger.Final Answer:
The main particle system has no collision module enabled -> Option BQuick Check:
Collision off = no collision trigger for sub-emitters [OK]
Hint: Enable collision module for collision-triggered sub-emitters [OK]
Common Mistakes:
- Not assigning sub-emitter particle system
- Setting wrong trigger type
- Having zero emission rate but expecting collisions
5. You want to create a firework effect where each main particle explodes into smaller sparks on death, and each spark also creates a small smoke puff on its own death. How do you set this up using sub-emitters?
hard
Solution
Step 1: Setup main particle system with death-triggered sparks
Add a sub-emitter to the main system that triggers on death to spawn spark particles.Step 2: Setup sparks particle system with death-triggered smoke
Add a sub-emitter to the sparks system that triggers on death to spawn smoke puffs.Step 3: Chain sub-emitters for layered effects
This chaining creates the firework effect with sparks and smoke triggered sequentially.Final Answer:
Add a sub-emitter to the main particle system triggered on death for sparks, then add a sub-emitter to the sparks system triggered on death for smoke -> Option AQuick Check:
Chain death-triggered sub-emitters for layered effects [OK]
Hint: Chain sub-emitters triggered on death for multi-layer effects [OK]
Common Mistakes:
- Adding all effects on birth triggers only
- Using one system with color changes only
- Avoiding sub-emitters and scripting manually
