onParticleCollision works, but ParticleSystem.GetCollisionEvents returns no events.

I’m trying to detect collisions for a flamethrower particle system. The idea is to get the normal of the collision, to instantiate another fire effect in the correct orientation.

I’ve looked around, and this seems to be done like this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FireDamage : MonoBehaviour
{
    [SerializeField] private ParticleSystem effect;
    private List<ParticleCollisionEvent> collisionEvents;

    // Start is called before the first frame update
    void Start()
    {
        collisionEvents = new List<ParticleCollisionEvent>();
    }

    // Update is called once per frame
    void Update()
    {
       
    }

    private void OnParticleCollision(GameObject other)
    {
        int num = effect.GetCollisionEvents(other, collisionEvents);

        Debug.Log("events" +other.name.ToString()+ ": "+num);

        foreach(ParticleCollisionEvent e in collisionEvents)
        {
            Instantiate(effect, e.intersection, Quaternion.LookRotation(e.normal, Vector3.up));
            Debug.Log("Instantiating effect on: " + other.name.ToString() + "at an angle of: " + e.normal.ToString());
        }
    }
}

Problem is, effect.GetCollisionEvents returns no events, the list is not populated resulting in me not getting the info i want. Any ideas? thx.

“Messages are only sent if you enable Send Collision Messages in the Inspector of the Particle System Collision module.”

Is this enabled on your game? I found this on the documentation page for OnParticleCollision

I’ve never used this API but I just confirmed it does work, with of course 100% of what the documentation above tells you to do.

See enclosed package.

7691536–962434–ParticleSystemColliders.unitypackage (353 KB)

Yes, it is enabled: 7691692--962467--upload_2021-11-27_20-50-34.png
Btw, the OnParticleCollision method DOES get called. The problem is that GetCollisionEvents doesn’t populate the list.