Bird
Raised Fist0
Unityframework~20 mins

Particle lifetime and speed in Unity - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Particle Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this particle lifetime calculation?
Consider a particle system where each particle's lifetime is set to 5 seconds and speed is 10 units per second. What is the total distance traveled by a particle before it disappears?
Unity
float lifetime = 5f;
float speed = 10f;
float distance = lifetime * speed;
Debug.Log($"Distance: {distance}");
ADistance: 10
BDistance: 50
CDistance: 5
DDistance: 15
Attempts:
2 left
💡 Hint
Distance is speed multiplied by time.
🧠 Conceptual
intermediate
1:30remaining
Which property controls how long a particle stays alive in Unity's Particle System?
In Unity's Particle System, which property directly sets the duration a particle exists before disappearing?
AStart Lifetime
BStart Speed
CEmission Rate
DGravity Modifier
Attempts:
2 left
💡 Hint
Think about how long a particle lasts.
🔧 Debug
advanced
2:30remaining
Why does this particle system not move particles as expected?
Given this code snippet, why do particles not move even though speed is set? ```csharp var ps = GetComponent(); var main = ps.main; main.startSpeed = 5f; ps.Play(); ``` Choose the correct reason.
AThe particle system is not playing because Play() was called before setting startSpeed.
BThe startSpeed property is read-only and cannot be set in code.
CParticles need a Rigidbody component to move with speed.
DThe particle system's simulation space is set to Local, so particles move with the system and appear stationary.
Attempts:
2 left
💡 Hint
Check the simulation space setting in the Particle System.
📝 Syntax
advanced
2:00remaining
Which code correctly sets particle lifetime and speed in Unity?
Select the code snippet that correctly sets the particle system's start lifetime to 3 seconds and start speed to 8 units per second.
A
var main = ps.main;
main.startLifetime = new ParticleSystem.MinMaxCurve(3f);
main.startSpeed = new ParticleSystem.MinMaxCurve(8f);
B
ps.startLifetime = 3f;
ps.startSpeed = 8f;
C
var main = ps.main;
main.startLifetime = 3f;
main.startSpeed = 8f;
D
var main = ps.main;
main.startLifetime = 3;
main.startSpeed = 8;
Attempts:
2 left
💡 Hint
startLifetime and startSpeed expect MinMaxCurve types.
🚀 Application
expert
3:00remaining
How to make particles slow down over their lifetime?
You want particles to start fast and gradually slow down until they stop before disappearing. Which approach achieves this in Unity's Particle System?
AIncrease startLifetime and decrease startSpeed in the main module.
BSet startSpeed to zero and increase it over time in Update().
CUse the 'Limit Velocity over Lifetime' module with a decreasing speed multiplier.
DAdd a Rigidbody and apply drag to slow particles.
Attempts:
2 left
💡 Hint
Look for modules that control speed changes over time.

Practice

(1/5)
1. What does the startLifetime property of a ParticleSystem control in Unity?
easy
A. How long each particle stays alive before disappearing
B. The speed at which particles move when emitted
C. The color of the particles over time
D. The size of the particles when they spawn

Solution

  1. Step 1: Understand the meaning of startLifetime

    The startLifetime property sets the duration each particle exists after being emitted.
  2. Step 2: Compare with other properties

    Speed controls movement, color controls appearance, size controls scale. Only lifetime controls duration.
  3. Final Answer:

    How long each particle stays alive before disappearing -> Option A
  4. Quick Check:

    Particle lifetime = duration alive [OK]
Hint: Lifetime means how long particles live before vanishing [OK]
Common Mistakes:
  • Confusing lifetime with speed
  • Thinking lifetime affects color or size
  • Mixing up startLifetime with emission rate
2. Which of the following is the correct way to set the particle speed to 5 in a Unity ParticleSystem script?
easy
A. particleSystem.startSpeed = 5f;
B. particleSystem.speed = 5;
C. particleSystem.setSpeed(5);
D. particleSystem.main.startSpeed = 5f;

Solution

  1. Step 1: Recall ParticleSystem API structure

    In Unity, startSpeed is inside the main module, accessed as particleSystem.main.startSpeed.
  2. Step 2: Check syntax correctness

    Options A and B are incorrect because startSpeed is not a direct property of ParticleSystem. particleSystem.setSpeed(5); uses a non-existent method.
  3. Final Answer:

    particleSystem.main.startSpeed = 5f; -> Option D
  4. Quick Check:

    Use main module to set startSpeed [OK]
Hint: Use particleSystem.main.startSpeed to set speed [OK]
Common Mistakes:
  • Trying to set startSpeed directly on particleSystem
  • Using incorrect method names
  • Forgetting to use the main module
3. Consider this Unity C# code snippet:
var ps = GetComponent<ParticleSystem>();
var main = ps.main;
main.startLifetime = 2f;
main.startSpeed = 3f;
Debug.Log(main.startLifetime + ", " + main.startSpeed);
What will be printed in the console?
medium
A. 2.0, 3.0
B. 2f, 3f
C. 2, 3
D. Error: Cannot assign to startLifetime

Solution

  1. Step 1: Understand property types and output

    The startLifetime and startSpeed are floats. Assigning 2f and 3f sets them to 2.0 and 3.0 internally.
  2. Step 2: Check Debug.Log output format

    Logging floats with string concatenation prints "2, 3" because ToString() on whole number floats omits the decimal.
  3. Final Answer:

    2, 3 -> Option C
  4. Quick Check:

    Whole number floats print without decimals [OK]
Hint: Whole number floats print without decimal in Debug.Log [OK]
Common Mistakes:
  • Expecting decimal output like 2.0, 3.0
  • Thinking 'f' suffix prints in output
  • Assuming assignment causes error
4. This code tries to set particle lifetime but causes an error:
var ps = GetComponent<ParticleSystem>();
ps.startLifetime = 4f;
What is the main problem?
medium
A. startLifetime must be set via the main module, not directly
B. startLifetime is a read-only property
C. ParticleSystem component is missing
D. startLifetime requires integer value, not float

Solution

  1. Step 1: Understand ParticleSystem property access

    In Unity, startLifetime is inside the main module, so it cannot be set directly on ps.
  2. Step 2: Identify correct way to set lifetime

    Correct syntax is var main = ps.main; main.startLifetime = 4f;. Direct assignment causes error.
  3. Final Answer:

    startLifetime must be set via the main module, not directly -> Option A
  4. Quick Check:

    Use main module to set startLifetime [OK]
Hint: Always set startLifetime via particleSystem.main [OK]
Common Mistakes:
  • Trying to set startLifetime directly on ParticleSystem
  • Assuming startLifetime is read-only
  • Confusing missing component with syntax error
5. You want to create a particle effect where particles live for 3 seconds and move faster over time, starting at speed 2 and increasing to 6. Which approach correctly sets this behavior in Unity?
hard
A. Set startLifetime = 3f and set startSpeed = 6f only
B. Set startLifetime = 3f and use velocityOverLifetime module to increase speed from 2 to 6
C. Set startLifetime = 6f and startSpeed = 2f
D. Set startLifetime = 3f and change speed in Update() manually

Solution

  1. Step 1: Set particle lifetime correctly

    Particles should live 3 seconds, so startLifetime = 3f is correct.
  2. Step 2: Use velocityOverLifetime for speed change

    To increase speed over time from 2 to 6, use the velocityOverLifetime module with a curve, not just startSpeed.
  3. Step 3: Evaluate other options

    Set startLifetime = 3f and set startSpeed = 6f only sets constant speed 6, not increasing. Set startLifetime = 6f and startSpeed = 2f has wrong lifetime. Set startLifetime = 3f and change speed in Update() manually is inefficient and unnecessary.
  4. Final Answer:

    Set startLifetime = 3f and use velocityOverLifetime module to increase speed from 2 to 6 -> Option B
  5. Quick Check:

    Use velocityOverLifetime for speed changes over time [OK]
Hint: Use velocityOverLifetime to change speed during particle life [OK]
Common Mistakes:
  • Setting only startSpeed for changing speed over time
  • Confusing lifetime and speed values
  • Trying to update speed manually every frame