0
0
Unityframework~5 mins

Emission and shape modules in Unity

Choose your learning style9 modes available
Introduction

The Emission and Shape modules help control how particles are created and where they come from in a particle system. This makes effects like smoke, fire, or sparks look real and interesting.

When you want particles to appear from a specific area or shape, like a circle or cone.
When you want to control how many particles are created over time or in bursts.
When creating effects like fireworks, smoke from a chimney, or rain from clouds.
When you want to make particles come from a moving object or follow a pattern.
When you want to adjust particle flow to match the mood or action in your game.
Syntax
Unity
var emission = particleSystem.emission;
emission.rateOverTime = 10f;

var shape = particleSystem.shape;
shape.shapeType = ParticleSystemShapeType.Cone;

You access the Emission and Shape modules through the main ParticleSystem object.

Each module has properties you can set to change how particles behave and appear.

Examples
This sets the particle system to emit 20 particles every second.
Unity
var emission = particleSystem.emission;
emission.rateOverTime = 20f;
This makes particles come from a sphere shape.
Unity
var shape = particleSystem.shape;
shape.shapeType = ParticleSystemShapeType.Sphere;
This creates bursts of particles at 0 and 1 second with 30 and 50 particles respectively.
Unity
var emission = particleSystem.emission;
emission.SetBursts(new ParticleSystem.Burst[] {
    new ParticleSystem.Burst(0f, 30),
    new ParticleSystem.Burst(1f, 50)
});
Sample Program

This script sets up a particle system to emit 15 particles per second from a cone shape with a 25-degree angle and 0.5 radius. Attach it to a GameObject with a ParticleSystem component.

Unity
using UnityEngine;

public class SimpleParticleSetup : MonoBehaviour
{
    public ParticleSystem particleSystem;

    void Start()
    {
        var emission = particleSystem.emission;
        emission.rateOverTime = 15f;

        var shape = particleSystem.shape;
        shape.shapeType = ParticleSystemShapeType.Cone;
        shape.angle = 25f;
        shape.radius = 0.5f;
    }
}
OutputSuccess
Important Notes

Changing emission rate affects how dense the particle effect looks.

Shape module controls where particles start, so changing it changes the effect's style.

Remember to assign the ParticleSystem component in the inspector or via code before using these modules.

Summary

The Emission module controls how many particles are created and when.

The Shape module controls the area or shape where particles come from.

Using both together helps create realistic and dynamic particle effects.