# TriggerSubEmitter

> Triggers the specified sub emitter on all particles of the Particle System.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.ParticleSystemModule

## TriggerSubEmitter(int)

Triggers the specified sub emitter on all particles of the Particle System.

```csharp
public void TriggerSubEmitter(int subEmitterIndex)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the sub emitter to trigger.

### Examples

```csharp
using UnityEngine;

// Add a manual sub-emitter
public class ExampleClass : MonoBehaviour
{
    private ParticleSystem ps;
    private float m_Timer = 0.0f;
    public float m_Interval = 2.0f;

    void Start()
    {
        // A simple particle material with no texture.
        Material particleMaterial = new Material(Shader.Find("Particles/Standard Unlit"));

        // Create a green Particle System.
        var rootSystemGO = new GameObject("Particle System");
        rootSystemGO.transform.Rotate(-90, 0, 0); // Rotate so the system emits upwards.
        ps = rootSystemGO.AddComponent<ParticleSystem>();
        rootSystemGO.GetComponent<ParticleSystemRenderer>().material = particleMaterial;
        var mainModule = ps.main;
        mainModule.startColor = Color.green;
        mainModule.startSize = 0.5f;

        // Create our sub-emitter and setup bursts.
        var subSystemGO = new GameObject("Particle System");
        var subParticleSystem = subSystemGO.AddComponent<ParticleSystem>();
        subSystemGO.GetComponent<ParticleSystemRenderer>().material = particleMaterial;
        var subMainModule = subParticleSystem.main;
        subMainModule.startColor = Color.red;
        subMainModule.startSize = 0.25f;
        var emissionModule = subParticleSystem.emission;
        emissionModule.SetBursts(new ParticleSystem.Burst[] { new ParticleSystem.Burst(0.0f, 4) }); // We will emit 10 particles when triggered.

        // Set up the sub-emitter.
        subSystemGO.transform.SetParent(rootSystemGO.transform);
        var subEmittersModule = ps.subEmitters;
        subEmittersModule.enabled = true;
        subEmittersModule.AddSubEmitter(subParticleSystem, ParticleSystemSubEmitterType.Manual, ParticleSystemSubEmitterProperties.InheritNothing);
    }

    private void Update()
    {
        m_Timer += Time.deltaTime;
        while (m_Timer >= m_Interval)
        {
            ps.TriggerSubEmitter(0);
            m_Timer -= m_Interval;
        }
    }
}
```

## TriggerSubEmitter(int, Particle)

Triggers the specified sub emitter on the specified particle(s) of the Particle System.

```csharp
public void TriggerSubEmitter(int subEmitterIndex, ref ParticleSystem.Particle particle)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the sub emitter to trigger.**** (\[Particle]\(/engine/6000.0/script-reference/unityengine/particlesystem/particle)): Triggers the sub emtter on a single particle.

## TriggerSubEmitter(int, List\<Particle>)

Triggers the specified sub emitter on the specified particle(s) of the Particle System.

```csharp
public void TriggerSubEmitter(int subEmitterIndex, List<ParticleSystem.Particle> particles)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Index of the sub emitter to trigger.**** (\[List\<Particle>]\(https\://learn.microsoft.com/dotnet/api/system.collections.generic.list-1)): Triggers the sub emtter on a list of particles.
