0
0
Unityframework~30 mins

Visual effect examples (fire, smoke, sparkle) in Unity - Mini Project: Build & Apply

Choose your learning style9 modes available
Visual effect examples (fire, smoke, sparkle)
📖 Scenario: You are creating a simple Unity scene to show three different visual effects: fire, smoke, and sparkle. These effects will help you understand how to add and control particle systems in Unity.
🎯 Goal: Build a Unity script that sets up three particle systems for fire, smoke, and sparkle effects. You will create variables to hold these effects, configure their basic settings, and then activate them in the scene.
📋 What You'll Learn
Create three public variables to hold ParticleSystem components for fire, smoke, and sparkle.
Add a configuration variable to control the duration each effect plays.
Write code to start playing each particle system for the set duration.
Print a message when all effects have finished playing.
💡 Why This Matters
🌍 Real World
Visual effects like fire, smoke, and sparkle are common in games and simulations to make scenes more lively and realistic.
💼 Career
Understanding how to control particle systems in Unity is a key skill for game developers and interactive media creators.
Progress0 / 4 steps
1
Create public ParticleSystem variables
Create three public variables called fireEffect, smokeEffect, and sparkleEffect of type ParticleSystem inside a class called VisualEffectsController.
Unity
Need a hint?

Declare three public variables of type ParticleSystem inside the class.

2
Add a duration configuration variable
Add a public float variable called effectDuration and set its default value to 5f inside the VisualEffectsController class.
Unity
Need a hint?

Add a public float variable named effectDuration and assign it the value 5f.

3
Play all effects for the duration
Inside the Start() method of VisualEffectsController, write code to play fireEffect, smokeEffect, and sparkleEffect. Then start a coroutine called StopEffectsAfterDelay() that stops all effects after effectDuration seconds.
Unity
Need a hint?

Use Play() on each effect in Start(). Then start a coroutine that waits for effectDuration seconds and stops each effect.

4
Print message when effects finish
In the StopEffectsAfterDelay() coroutine, after stopping all effects, add a line to print "All effects finished playing." to the console.
Unity
Need a hint?

Use Debug.Log("All effects finished playing.") to print the message after stopping the effects.