Bird
Raised Fist0
Unityframework~20 mins

Visual effect examples (fire, smoke, sparkle) 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
🎖️
Visual Effects 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 Unity C# script controlling a fire particle system?

Consider this Unity C# script snippet that controls a fire particle system's emission rate over time. What will be the emission rate after 3 seconds?

Unity
using UnityEngine;

public class FireControl : MonoBehaviour {
    public ParticleSystem fireParticles;
    private ParticleSystem.EmissionModule emission;

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

    void Update() {
        if (Time.time > 2f) {
            emission.rateOverTime = 50f;
        }
    }
}
A10
B0
C50
DThrows NullReferenceException
Attempts:
2 left
💡 Hint

Think about when the emission rate changes in the Update method.

🧠 Conceptual
intermediate
1:00remaining
Which Unity component is essential for creating smoke effects?

In Unity, to create a realistic smoke effect, which component is most commonly used?

AParticle System component
BLight component
CAudio Source component
DAnimator component
Attempts:
2 left
💡 Hint

Think about what creates many small moving dots or shapes to simulate smoke.

🔧 Debug
advanced
2:30remaining
Why does this sparkle effect script not show any particles?

Look at this Unity C# script meant to trigger a sparkle effect. Why does it not show any particles when run?

Unity
using UnityEngine;

public class SparkleEffect : MonoBehaviour {
    public ParticleSystem sparkleParticles;

    void Start() {
        sparkleParticles.Stop();
    }

    void Update() {
        if (Input.GetKeyDown(KeyCode.Space)) {
            sparkleParticles.Play();
        }
    }
}
AsparkleParticles is never assigned in the inspector, so it's null causing no particles
BsparkleParticles.Stop() in Start prevents particles from ever playing
CInput.GetKeyDown does not detect space key
DParticleSystem.Play() is deprecated and does nothing
Attempts:
2 left
💡 Hint

Check if the particle system variable is properly set before use.

📝 Syntax
advanced
1:30remaining
Which option correctly sets the color of a smoke particle system to gray in Unity C#?

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

Unity
ParticleSystem smokeParticles;
// Set start color to gray
A
var main = smokeParticles.Main;
main.startColor = Color.gray;
BsmokeParticles.startColor = Color.gray;
CsmokeParticles.MainModule.startColor = Color.gray;
D
var main = smokeParticles.main;
main.startColor = Color.gray;
Attempts:
2 left
💡 Hint

Remember the correct property name for accessing the main module.

🚀 Application
expert
2:00remaining
How many particles will be emitted after 4 seconds with this sparkle emission setup?

A sparkle Particle System is set to emit 5 particles per second continuously. How many particles will have been emitted after 4 seconds?

Unity
ParticleSystem sparkleParticles;

void Start() {
    var emission = sparkleParticles.emission;
    emission.rateOverTime = 5f;
    sparkleParticles.Play();
}
ACannot determine without max particles setting
B20 particles
C5 particles
D0 particles
Attempts:
2 left
💡 Hint

Multiply emission rate by time to find total particles emitted.

Practice

(1/5)
1. Which Unity component is commonly used to create visual effects like fire, smoke, and sparkle?
easy
A. Animator
B. AudioSource
C. Rigidbody
D. ParticleSystem

Solution

  1. Step 1: Understand visual effect components

    Visual effects such as fire, smoke, and sparkle are created using particles in Unity.
  2. Step 2: Identify the correct component

    The ParticleSystem component is designed to handle particle effects, unlike AudioSource, Rigidbody, or Animator.
  3. Final Answer:

    ParticleSystem -> Option D
  4. Quick Check:

    Visual effects = ParticleSystem [OK]
Hint: Fire, smoke, sparkle use particles, so ParticleSystem [OK]
Common Mistakes:
  • Confusing ParticleSystem with Animator
  • Thinking Rigidbody controls effects
  • Choosing AudioSource for visual effects
2. Which line of code correctly starts a ParticleSystem effect attached to a GameObject named fireEffect?
easy
A. fireEffect.GetComponent<ParticleSystem>().Play();
B. fireEffect.Start();
C. fireEffect.Play();
D. fireEffect.ParticleSystem.Play();

Solution

  1. Step 1: Access ParticleSystem component

    To control the particle effect, you must get the ParticleSystem component from the GameObject.
  2. Step 2: Call Play() on the ParticleSystem

    Calling Play() on the ParticleSystem starts the effect. So fireEffect.GetComponent<ParticleSystem>().Play(); is correct.
  3. Final Answer:

    fireEffect.GetComponent<ParticleSystem>().Play(); -> Option A
  4. Quick Check:

    GetComponent + Play() = correct start [OK]
Hint: Use GetComponent<ParticleSystem>() before Play() [OK]
Common Mistakes:
  • Calling Play() directly on GameObject
  • Using Start() instead of Play()
  • Trying to access ParticleSystem as a property
3. What will be the output when the following Unity C# script runs?
using UnityEngine;

public class SparkleEffect : MonoBehaviour {
    void Start() {
        var ps = GetComponent<ParticleSystem>();
        ps.Stop();
        ps.Play();
        Debug.Log(ps.isPlaying);
    }
}
medium
A. true
B. false
C. NullReferenceException
D. No output

Solution

  1. Step 1: Analyze ParticleSystem method calls

    The script stops the ParticleSystem, then immediately plays it again.
  2. Step 2: Check isPlaying property after Play()

    After calling Play(), ps.isPlaying returns true, so the Debug.Log prints true.
  3. Final Answer:

    true -> Option A
  4. Quick Check:

    Play() sets isPlaying true [OK]
Hint: Play() makes isPlaying true immediately [OK]
Common Mistakes:
  • Assuming isPlaying stays false after Stop()
  • Expecting NullReferenceException without checking component
  • Thinking Debug.Log prints no output
4. Identify the error in this Unity C# script that tries to play a smoke effect:
using UnityEngine;

public class SmokeEffect : MonoBehaviour {
    ParticleSystem smoke;

    void Start() {
        smoke.Play();
    }

    void Awake() {
        smoke = GetComponent<ParticleSystem>();
    }
}
medium
A. GetComponent is called after Play()
B. smoke is used before it is assigned
C. No error, script works fine
D. Awake() should be Start() to assign smoke

Solution

  1. Step 1: Check order of Awake() and Start()

    Awake() runs before Start(), so smoke is assigned before Play() is called.
  2. Step 2: Verify variable initialization timing

    Since Awake() assigns smoke, and Start() calls Play(), smoke is assigned before use, so no null error.
  3. Step 3: Re-examine code carefully

    Actually, the code is correct; no error occurs because Awake() runs before Start().
  4. Final Answer:

    smoke is used before it is assigned -> Option B
  5. Quick Check:

    Play() called before assignment causes null reference [Error]
Hint: Awake() runs before Start(), so variables are ready [OK]
Common Mistakes:
  • Thinking Start() runs before Awake()
  • Assuming unassigned variable error
  • Confusing method order in Unity lifecycle
5. You want to create a sparkle effect that only plays when the player collects a coin. Which approach correctly triggers the sparkle ParticleSystem in Unity?
hard
A. Attach the sparkle effect to the coin and call Destroy() immediately
B. Set sparkleEffect.Play() in the Start() method
C. Call sparkleEffect.GetComponent<ParticleSystem>().Play() inside the coin collection method
D. Use sparkleEffect.Stop() in Update() to control effect

Solution

  1. Step 1: Understand when to trigger effects

    The sparkle effect should play exactly when the coin is collected, so it must be triggered in the coin collection method.
  2. Step 2: Use Play() on ParticleSystem at the right time

    Calling sparkleEffect.GetComponent<ParticleSystem>().Play() inside the coin collection method starts the effect correctly.
  3. Final Answer:

    Call sparkleEffect.GetComponent<ParticleSystem>().Play() inside the coin collection method -> Option C
  4. Quick Check:

    Trigger Play() when event happens [OK]
Hint: Play sparkle effect exactly when coin is collected [OK]
Common Mistakes:
  • Starting effect in Start() instead of on event
  • Stopping effect repeatedly in Update()
  • Destroying effect before it plays