How to detect when and where a particle hits a surface?

I’m trying to create an obstacle where meteors are falling onto the map and if they hit, it causes an explosions, at the point of contact, and throws back anything with a rigidbody.

The main issue is I cannot find a way to detect the particle collision (meteors) when the reach the plane (map).

I’ve tried OnParticleCollision, but to no avail. I’ve been at it for a couple hours and I feel I’ve exhausted all possible errors.

If there is something I’m overlooking or a better way of going about this task, I would greatly appreciate any help.

Thank you and have a good one.

The OnParticleCollision method should be what you’re looking for. I’m implementing a magic spell system that uses particle collisions for damage, and it works pretty reliably.

Here’s my solution,
In the Master Particle System (the one where each particle represents your meteor, not it’s trails or sparks or whatever)

  • Enable the “Collision” tab in the particle Inspector
  • Enable the “Send Collision Messages” checkbox in the tab
  • Set Collision Mode to “World” and “3D”
  • Enable “Enable Dynamic Colliders”

In a script that is attached to the same game object this particle system is (this is important, they have to be on the same object), implement the function like so:

private ParticleSystem PSystem;
    private ParticleCollisionEvent[] CollisionEvents;

// Grab your PSystem in Start or Awake method via GetComponent, and also:

//In Start or such:
CollisionEvents = new ParticleCollisionEvent[8];

//Then, in this callback function:

public void OnParticleCollision(GameObject other)
        int collCount = PSystem.GetSafeCollisionEventSize();

        if (collCount > CollisionEvents.Length)
            CollisionEvents = new ParticleCollisionEvent[collCount];

        int eventCount = PSystem.GetCollisionEvents(other, CollisionEvents);

        for (int i = 0; i < eventCount; i++)
                //TODO: Do your collision stuff here. 
               // You can access the CollisionEvent *to obtaion point of intersection, normals that kind of thing*

// You can simply use “other” GameObject to access it’s rigidbody to apply force, or check if it implements a class that takes damage or whatever
It is a bit weird, considering how normally these kind of events are easily accessed in Unity’s scripting but there you go, this is the way to do this particular example.

@Eudaimonium Damn, the above solution is now obsolete.

How do I update

PSystem.GetCollisionEvents(other, CollisionEvents);?

For anyone wondering how to do this today, this tutorial goes through the current correct api usage.

GetCollisionEvents function using ParticleCollisionEvent[] is deprecated. Use List<ParticleCollisionEvent> instead. You can use this as example:

private List<ParticleCollisionEvent> _particleCollisionEvents = new List<ParticleCollisionEvent>();
var eventCount = playerLaser.GetCollisionEvents(gameObject, _particleCollisionEvents);