Bird
Raised Fist0
Unityframework~20 mins

Particle System component 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 System Master
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 System emission rate code?

Consider this Unity C# script snippet that modifies a Particle System's emission rate over time. What will be the emission rate after 3 seconds?

Unity
using UnityEngine;

public class ParticleEmissionTest : MonoBehaviour
{
    public ParticleSystem ps;

    void Start()
    {
        var emission = ps.emission;
        emission.rateOverTime = 10f;
    }

    void Update()
    {
        var emission = ps.emission;
        emission.rateOverTime = 10f + Time.time * 5f;
    }
}
A10 particles per second
B15 particles per second
C25 particles per second
D30 particles per second
Attempts:
2 left
💡 Hint

Remember that Time.time gives the time in seconds since the game started.

🧠 Conceptual
intermediate
1:30remaining
Which property controls the shape of particle emission?

In Unity's Particle System component, which property lets you change the shape from which particles are emitted?

Ashape.shapeType
Bshape.enabled
Cmain.startSize
Demission.rateOverTime
Attempts:
2 left
💡 Hint

Think about the module that defines the geometry of emission.

🔧 Debug
advanced
2:00remaining
Why does this Particle System not emit particles?

Look at this code snippet. The Particle System does not emit any particles when the game runs. What is the cause?

Unity
using UnityEngine;

public class ParticleDebug : MonoBehaviour
{
    public ParticleSystem ps;

    void Start()
    {
        var emission = ps.emission;
        emission.enabled = false;
        ps.Play();
    }
}
AThe Particle System variable ps is not assigned.
BEmission is disabled, so no particles are emitted.
CParticle System is not playing because Play() is called in Start().
DThe emission rate is zero by default.
Attempts:
2 left
💡 Hint

Check the emission module's enabled state.

📝 Syntax
advanced
1:30remaining
Which code correctly sets the start color of a Particle System?

Choose the correct code snippet to set the start color of a Particle System to red.

A
var main = ps.main;
main.startColor = Color.red;
B
var main = ps.main;
main.startColor = new Color(1, 0, 0);
Cps.main.startColor = Color.red;
Dps.startColor = Color.red;
Attempts:
2 left
💡 Hint

The main module is a struct; you must assign its properties correctly.

🚀 Application
expert
3:00remaining
How to smoothly increase particle size over lifetime?

You want particles to start small and grow bigger smoothly as they live. Which code snippet achieves this effect?

A
var main = ps.main;
main.startSize = 1f;
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.enabled = true;
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.Linear(0, 1f, 1, 2f));
B
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.enabled = true;
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.Linear(0, 0.1f, 1, 1));
C
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.enabled = true;
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.Linear(0, 0.1f, 1, 1f));
D
var sizeOverLifetime = ps.sizeOverLifetime;
sizeOverLifetime.enabled = true;
sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, AnimationCurve.Linear(0, 1f, 1, 2f));
Attempts:
2 left
💡 Hint

Think about the size curve from 1 to 2 over the particle lifetime.

Practice

(1/5)
1. What is the main purpose of the Particle System component in Unity?
easy
A. To control the physics of a GameObject
B. To handle user input events
C. To manage audio playback in the scene
D. To create visual effects like fire, smoke, or sparks

Solution

  1. Step 1: Understand Particle System role

    The Particle System component is designed to create many small moving images that simulate effects such as fire, smoke, or sparks.
  2. Step 2: Compare with other options

    Options A, C, and D describe other Unity systems like physics, audio, and input, which are not related to Particle Systems.
  3. Final Answer:

    To create visual effects like fire, smoke, or sparks -> Option D
  4. Quick Check:

    Particle System = Visual effects [OK]
Hint: Particle System = visual effects like fire or smoke [OK]
Common Mistakes:
  • Confusing Particle System with physics or audio components
  • Thinking it handles user input
  • Assuming it controls GameObject movement
2. Which of the following is the correct way to start a Particle System named ps in a C# script?
easy
A. ps.Play();
B. ps.Start();
C. ps.Begin();
D. ps.Run();

Solution

  1. Step 1: Recall Particle System methods

    The Particle System class in Unity uses the method Play() to start emitting particles.
  2. Step 2: Check other options

    Methods like Start(), Begin(), and Run() do not exist for Particle System and will cause errors.
  3. Final Answer:

    ps.Play(); -> Option A
  4. Quick Check:

    Start Particle System = Play() method [OK]
Hint: Use Play() to start Particle System in scripts [OK]
Common Mistakes:
  • Using Start() instead of Play()
  • Trying non-existent methods like Begin()
  • Confusing with coroutine or animation methods
3. Given this code snippet, what will be the output in the Unity Console?
ParticleSystem ps = GetComponent<ParticleSystem>();
ps.Stop();
if (ps.isPlaying)
    Debug.Log("Playing");
else
    Debug.Log("Stopped");
medium
A. Stopped
B. No output
C. Error: isPlaying not found
D. Playing

Solution

  1. Step 1: Understand the code flow

    The code stops the Particle System with ps.Stop(); then checks if it is playing using ps.isPlaying.
  2. Step 2: Evaluate the condition

    Since the system was stopped, ps.isPlaying will be false, so the else branch runs and prints "Stopped".
  3. Final Answer:

    Stopped -> Option A
  4. Quick Check:

    Stopped after ps.Stop() = "Stopped" output [OK]
Hint: ps.isPlaying is false after ps.Stop() [OK]
Common Mistakes:
  • Assuming isPlaying stays true after Stop()
  • Thinking Stop() pauses but keeps playing
  • Expecting no output from Debug.Log
4. What is wrong with this code snippet that tries to change the particle color?
ParticleSystem ps = GetComponent<ParticleSystem>();
ps.startColor = Color.red;
medium
A. Color.red is not a valid color
B. startColor is deprecated; must use main module
C. GetComponent<ParticleSystem>() returns null
D. Cannot assign color directly to ParticleSystem

Solution

  1. Step 1: Identify property usage

    The startColor property is deprecated in recent Unity versions; color must be set via the main module.
  2. Step 2: Correct way to set color

    Use var main = ps.main; main.startColor = Color.red; to change particle color properly.
  3. Final Answer:

    startColor is deprecated; must use main module -> Option B
  4. Quick Check:

    Use main.startColor, not ps.startColor [OK]
Hint: Use ps.main.startColor to set color, not ps.startColor [OK]
Common Mistakes:
  • Using deprecated startColor property directly
  • Assuming Color.red is invalid
  • Not accessing main module before setting color
5. You want to create a Particle System that emits particles only when the player presses the spacebar. Which code snippet correctly achieves this behavior inside Update()?
hard
A. if (Input.GetKeyDown(KeyCode.Space)) { ps.Stop(); }
B. if (Input.GetKey(KeyCode.Space)) { ps.Stop(); } else { ps.Play(); }
C. if (Input.GetKeyDown(KeyCode.Space)) { ps.Play(); } else { ps.Stop(); }
D. if (Input.GetKeyUp(KeyCode.Space)) { ps.Play(); }

Solution

  1. Step 1: Understand input and particle control

    We want particles to emit only when the player presses the spacebar. Using GetKeyDown detects the press moment, so we start playing particles then.
  2. Step 2: Control particle emission correctly

    if (Input.GetKeyDown(KeyCode.Space)) { ps.Play(); } else { ps.Stop(); } starts particles on space press and stops them otherwise, ensuring particles emit only during spacebar press.
  3. Final Answer:

    if (Input.GetKeyDown(KeyCode.Space)) { ps.Play(); } else { ps.Stop(); } -> Option C
  4. Quick Check:

    Play on space press, stop otherwise [OK]
Hint: Use Play() to start Particle System in scripts [OK]
Common Mistakes:
  • Using GetKey instead of GetKeyDown causing continuous play
  • Stopping particles on key press instead of play
  • Not stopping particles when key is released