0
0
Unityframework~10 mins

Particle lifetime and speed in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the particle system's start lifetime to 5 seconds.

Unity
var particleSystem = GetComponent<ParticleSystem>();
var main = particleSystem.main;
main.startLifetime = [1]f;
Drag options to blanks, or click blank then click option'
A5
B10
C0
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using an integer without 'f' suffix causes a type error.
Setting lifetime to 0 means particles die immediately.
2fill in blank
medium

Complete the code to set the particle system's start speed to 3 units per second.

Unity
var particleSystem = GetComponent<ParticleSystem>();
var main = particleSystem.main;
main.startSpeed = [1]f;
Drag options to blanks, or click blank then click option'
A0
B10
C-3
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using negative speed values.
Forgetting the 'f' suffix for floats.
3fill in blank
hard

Fix the error in setting the particle lifetime to 0 (which disables particles). Use 1 second instead.

Unity
var particleSystem = GetComponent<ParticleSystem>();
var main = particleSystem.main;
main.startLifetime = [1]f;
Drag options to blanks, or click blank then click option'
A-1
B1
C0
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Setting lifetime to zero disables particles.
Using negative values causes errors.
4fill in blank
hard

Fill both blanks to set the particle system's start lifetime to 2 seconds and start speed to 4 units per second.

Unity
var particleSystem = GetComponent<ParticleSystem>();
var main = particleSystem.main;
main.startLifetime = [1]f;
main.startSpeed = [2]f;
Drag options to blanks, or click blank then click option'
A2
B3
C4
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up lifetime and speed values.
Using zero or negative values.
5fill in blank
hard

Fill all three blanks to create a particle system, set start lifetime to 3 seconds, start speed to 6 units per second, and enable looping.

Unity
var particleSystem = gameObject.AddComponent<ParticleSystem>();
var main = particleSystem.main;
main.startLifetime = [1]f;
main.startSpeed = [2]f;
main.loop = [3];
Drag options to blanks, or click blank then click option'
Atrue
B6
C3
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing true/false for loop property.
Swapping lifetime and speed values.