0
0
Unityframework~10 mins

Particle lifetime and speed in Unity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Particle lifetime and speed
Start Particle System
Set Particle Speed
Set Particle Lifetime
Emit Particles
Particles Move
Particles Expire After Lifetime
End
This flow shows how particles are created with speed and lifetime, move accordingly, and then disappear after their lifetime ends.
Execution Sample
Unity
var ps = GetComponent<ParticleSystem>();
var main = ps.main;
main.startSpeed = 5f;
main.startLifetime = 3f;
ps.Emit(1);
This code sets particle speed to 5 units/sec, lifetime to 3 seconds, then emits one particle.
Execution Table
StepActionParticle SpeedParticle LifetimeParticle AgeParticle PositionParticle State
1Set startSpeed to 55---No particles yet
2Set startLifetime to 353--No particles yet
3Emit 1 particle530(0,0,0)Alive
4After 1 second531(5,0,0)Alive
5After 2 seconds532(10,0,0)Alive
6After 3 seconds533(15,0,0)Dead (expired)
7After 3.1 seconds533.1(15.5,0,0)Dead (expired)
💡 Particle expires after 3 seconds lifetime, so it is removed at step 6.
Variable Tracker
VariableStartAfter Step 3After Step 4After Step 5After Step 6After Step 7
Particle Speed-55555
Particle Lifetime-33333
Particle Age-01233.1
Particle Position (x)-05101515.5
Particle StateNo particlesAliveAliveAliveDeadDead
Key Moments - 3 Insights
Why does the particle disappear after 3 seconds?
Because the particle's lifetime is set to 3 seconds (see execution_table step 6), it expires and is removed after that time.
How does particle speed affect its position?
Particle speed determines how far it moves each second. At speed 5, after 1 second it moves 5 units (execution_table step 4).
What happens if we emit a particle but don't set lifetime?
The particle uses the default lifetime from the ParticleSystem. Without setting it explicitly, it may live longer or shorter depending on defaults.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the particle's position after 2 seconds?
A(5,0,0)
B(15,0,0)
C(10,0,0)
D(0,0,0)
💡 Hint
Check the 'Particle Position' column at step 5 in the execution_table.
At which step does the particle expire and become dead?
AStep 4
BStep 6
CStep 7
DStep 3
💡 Hint
Look at the 'Particle State' column in the execution_table for when it changes to 'Dead'.
If we change startSpeed to 10, what will be the particle's position after 1 second?
A(10,0,0)
B(5,0,0)
C(15,0,0)
D(0,0,0)
💡 Hint
Particle position after 1 second equals speed * time; see variable_tracker for position updates.
Concept Snapshot
Particle lifetime and speed in Unity:
- Use ParticleSystem.main.startSpeed to set speed.
- Use ParticleSystem.main.startLifetime to set how long particles live.
- Emit particles with Emit(count).
- Particles move at speed until lifetime expires, then disappear.
Full Transcript
This visual execution shows how Unity's ParticleSystem uses startSpeed and startLifetime to control particle behavior. First, speed and lifetime are set. Then a particle is emitted at position zero with age zero. Each second, the particle moves forward by speed units. After 3 seconds, the particle's age exceeds its lifetime and it is removed. The tables track speed, lifetime, age, position, and state step-by-step. Key moments clarify why particles disappear and how speed affects movement. Quizzes test understanding of position at times and expiration timing.