Working with Particle Systems

Make explosions, sparks, smoke, dust and rain, and control them from your scripts.

A Particle System is a confetti cannon with a lot of dials. One dial sets how many pieces fly out, another sets which direction, another how long each piece lasts, another what colour it fades to. Each piece of confetti (a particle) is just a tiny picture that always faces the camera.

Make your first effect

  1. GameObject > Effects > Particle System. White dots start floating upward.
  2. With it selected, a small Particle Effect panel appears in the Scene view with Play, Restart and Stop buttons, so you can preview without entering Play mode.
  3. In the Inspector, the settings are split into modules. Click a module's name to open it and tick its box to turn it on.

The modules you'll use most

ModuleControlsKey settings
Main (top section)Each particle's starting lookDuration, Looping, Start Lifetime, Start Speed, Start Size, Start Color, Gravity Modifier, Simulation Space
EmissionHow many come outRate over Time (steady stream) or Bursts (all at once)
ShapeWhere they come from and which way they goCone, Sphere, Box, Circle, Edge, Mesh
Color over LifetimeColour and fade as they ageA gradient: set alpha to 0 at the end to fade out
Size over LifetimeGrow or shrink as they ageA curve from 1 down to 0 looks like sparks burning out
NoiseWobbly, natural movementStrength, Frequency
CollisionBounce off the worldType: World, Bounce, Lifetime Loss
RendererWhat each particle looks likeMaterial, Render Mode (Billboard, Stretched, Mesh)

Tip: many values have a small ▼ next to them. Choose Random Between Two Constants to add variety, e.g. Start Size 0.1 to 0.3. Variety is what makes effects look natural.

Recipes

Explosion burst

Dust puffs behind a running character

Rain

Local vs World simulation space

Localparticles move with the emitterWorldparticles stay behind: a trail
Main module > Simulation Space. Use Local for a torch flame or jet engine, World for smoke trails, footstep dust and rain.

Controlling particles from code

using UnityEngine;

public class ParticleExamples : MonoBehaviour
{
    [SerializeField] private ParticleSystem sparks;

    void Examples()
    {
        sparks.Play();      // start emitting
        sparks.Stop();      // stop emitting; existing particles finish their life
        sparks.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); // vanish now
        sparks.Emit(20);    // spit out 20 particles immediately, even if stopped

        bool busy = sparks.IsAlive();   // true while any particle is still visible
    }
}

Changing settings: the module gotcha

Modules must be copied into a local variable first. You can't set them in one line:

// ❌ Won't compile
sparks.main.startColor = Color.red;

// ✅ Grab the module, then change it. It still updates the real system.
var main = sparks.main;
main.startColor = Color.red;
main.startSpeed = 8f;

var emission = sparks.emission;
emission.rateOverTime = 50f;

The variable is a handle to the particle system, not a copy of the data. Changing it changes the real effect.

Example: play a hit effect where a bullet lands

using UnityEngine;

public class HitEffect : MonoBehaviour
{
    [SerializeField] private ParticleSystem hitPrefab;

    void OnCollisionEnter(Collision collision)
    {
        ContactPoint contact = collision.GetContact(0);
        // Face the effect away from the surface that was hit
        Quaternion rotation = Quaternion.LookRotation(contact.normal);

        Instantiate(hitPrefab, contact.point, rotation); // a cone shape sprays along the blue Z arrow
        // On the prefab: Looping off, Stop Action = Destroy, so it cleans itself up
    }
}

The Stop Action (in the Main module) decides what happens when the effect finishes: Destroy removes the GameObject, Disable switches it off, Callback calls OnParticleSystemStopped() on your script. If effects spawn often, pool them using Disable or Callback instead of Destroy.

Play() / BurstParticles bornAge: colour & size changeLifetime endsStop Action
Every particle goes through this; the system finishes when the last one dies.

Sub Emitters: effects inside effects

The Sub Emitters module starts a second particle system when a particle is born, dies or collides. Classic use: a firework rocket particle that triggers a burst explosion when it dies.

Materials in URP

Particles need a particle material. In URP, create a material with Universal Render Pipeline/Particles/Unlit (or Lit if it should react to lights), set Surface Type to Transparent, and give it a soft round texture. Then drag it into the Renderer module's Material slot. Pink particles mean the material isn't a URP one.

Keep it fast

Common Mistakes

See also