0
0
Unityframework~20 mins

Particle collision in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Particle Collision 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 OnParticleCollision method?

Consider this Unity C# script snippet attached to a GameObject with a Particle System. What will be printed when a particle collides with another GameObject?

Unity
void OnParticleCollision(GameObject other) {
    Debug.Log($"Collided with: {other.name}");
}
AThe console prints: "Collided with: " followed by the name of the other GameObject.
BNothing is printed because OnParticleCollision is never called automatically.
CThe console prints "Particle collided" regardless of the other GameObject's name.
DA runtime error occurs because OnParticleCollision requires a ParticleSystem parameter.
Attempts:
2 left
💡 Hint

OnParticleCollision is a Unity event method triggered automatically when particles collide with other GameObjects.

🧠 Conceptual
intermediate
2:00remaining
Which component must be enabled for particle collisions to trigger OnParticleCollision?

In Unity, to detect particle collisions and trigger the OnParticleCollision method, which setting must be enabled on the Particle System?

ASet the Particle System's 'Play On Awake' to false.
BAdd a Rigidbody component to the Particle System GameObject.
CEnable the 'Collision' module in the Particle System and set 'Send Collision Messages' to true.
DEnable the 'Trigger' module in the Particle System.
Attempts:
2 left
💡 Hint

Look for the module that controls particle interactions with other objects.

🔧 Debug
advanced
2:00remaining
Why does this OnParticleCollision method never print anything?

Examine the following code attached to a GameObject with a Particle System. Despite particles colliding with other objects, nothing is printed in the console. What is the most likely cause?

Unity
void OnParticleCollision() {
    Debug.Log("Particle collided");
}
AThe Debug.Log statement is inside the wrong method; it should be in Update().
BThe Particle System's emission rate is set to zero.
CThe Particle System is missing a Collider component.
DThe method signature is incorrect; it must have a GameObject parameter to be called.
Attempts:
2 left
💡 Hint

Check the method signature required by Unity for particle collision callbacks.

📝 Syntax
advanced
2:00remaining
Which option correctly implements OnParticleCollision to count collisions?

You want to count how many particles collided with other objects. Which code correctly increments a collision count each time a particle collides?

Unity
int collisionCount = 0;

// Your OnParticleCollision method here
A
void OnParticleCollision(GameObject other) {
    collisionCount++;
}
B
void OnParticleCollision() {
    collisionCount++;
}
C
void OnParticleCollision(GameObject other) {
    collisionCount += other.GetInstanceID();
}
D
void OnParticleCollision(Collider other) {
    collisionCount++;
}
Attempts:
2 left
💡 Hint

Check the required method signature and parameter types for OnParticleCollision.

🚀 Application
expert
3:00remaining
How to detect which particles collided and get their positions?

You want to detect each individual particle that collided and get its position during the collision event. Which approach correctly achieves this in Unity?

AUse <code>ParticleSystem.EmitParams.position</code> inside OnParticleCollision to get collided particle positions.
BUse <code>ParticleSystem.GetCollisionEvents(GameObject, List&lt;ParticleCollisionEvent&gt;)</code> inside OnParticleCollision to get collision details including positions.
CUse <code>OnParticleCollision(GameObject other)</code> and access <code>other.transform.position</code> for particle positions.
DAdd a Collider to each particle and use OnCollisionEnter to get positions.
Attempts:
2 left
💡 Hint

Look for a ParticleSystem method that provides detailed collision event info.