Particle lifetime and speed control how long particles last and how fast they move. This helps make effects like fire, smoke, or magic look real and interesting.
0
0
Particle lifetime and speed in Unity
Introduction
When creating a fire effect that fades out after a few seconds.
When making smoke that slowly rises and disappears.
When simulating sparks that shoot out quickly and vanish.
When adjusting rain particles to fall at different speeds.
When customizing magic spell effects with varying particle durations.
Syntax
Unity
var main = particleSystem.main; main.startLifetime = 2.0f; // seconds main.startSpeed = 5.0f; // units per second
You access lifetime and speed through the main module of the ParticleSystem.
Both startLifetime and startSpeed can be set to a constant or a range.
Examples
Sets all particles to live 3 seconds and move at speed 4.
Unity
var main = particleSystem.main; main.startLifetime = 3.0f; main.startSpeed = 4.0f;
Particles will have random lifetimes between 1 and 5 seconds, and speeds between 2 and 6.
Unity
var main = particleSystem.main; main.startLifetime = new ParticleSystem.MinMaxCurve(1.0f, 5.0f); main.startSpeed = new ParticleSystem.MinMaxCurve(2.0f, 6.0f);
Particles live half a second and move very fast.
Unity
var main = particleSystem.main; main.startLifetime = 0.5f; main.startSpeed = 10.0f;
Sample Program
This script sets the particle system so each particle lasts 2.5 seconds and moves at speed 3 when the game starts.
Unity
using UnityEngine; public class ParticleControl : MonoBehaviour { public ParticleSystem particleSystem; void Start() { var main = particleSystem.main; main.startLifetime = 2.5f; // particles live 2.5 seconds main.startSpeed = 3.0f; // particles move at speed 3 } }
OutputSuccess
Important Notes
Changing lifetime affects how long particles stay visible before disappearing.
Speed controls how fast particles move away from their source.
You can use ranges to add variety and make effects look more natural.
Summary
Particle lifetime controls how long particles last.
Particle speed controls how fast particles move.
Both are set through the particle system's main module.