Course contentsShow
← Unity Game Development
Lesson 651 of 82810. VFX and Post-ProcessingFree lesson

Controlling Particle Collision and Trigger Interactivity

Learners will implement physics-based particle reactions to ensure effects interact realistically with the game environment and colliders.

In this lesson, you will learn how to make your particle systems physically reactive, allowing them to bounce off surfaces or trigger game logic upon impact.

By default, particles are purely visual and pass through game objects. To create realistic effects—like sparks hitting a floor or rain splashing against a wall—we use the Collision module. When enabled, Unity treats each particle as a physical sphere, allowing it to collide with static or dynamic Colliders in your scene.

Configuring Collision

Inside the Particle System inspector, enable the Collision module. Set the type to World to detect collisions against your environment. You can tune the Dampen and Bounce properties to control how energy is lost or maintained upon impact, which is essential for differentiating between heavy debris and light embers.

Trigger Interactivity

While the Collision module handles physics, the Trigger module allows your particles to "talk" to your game code. By enabling the Trigger module, you can define specific Colliders that trigger an event when particles enter, exit, or stay within their boundaries.

For example, you can detect when particles enter a "Kill Zone" collider to destroy them prematurely, or trigger a sound effect:

void OnParticleTrigger()
{
    List<ParticleSystem.Particle> inside = new List<ParticleSystem.Particle>();
    int numInside = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, inside);
    
    // Logic: If a particle enters the trigger zone, play a specific sound or effect
    if (numInside > 0) {
        Debug.Log("Particle impact detected!");
    }
}

Optimization Note

Particle collisions are computationally expensive. Because you have already learned about optimizing shaders and occlusion culling, remember to apply that same mindset here. Always set your Collision Quality to Low if you have high particle counts, and use Visualization tools in the Scene view to ensure you aren't calculating collisions for particles that are hidden behind your camera’s clipping planes.

Key Takeaway: Use the Collision module for physical interaction with the world and the Trigger module to bridge the gap between visual effects and your game’s functional logic.