Collisions don't work with a particle system created via code

Hi everyone, I’m working on a project where I create a particle system using a csv file where the id, x,y,z data are stored. The particle system is created correctly but although the “Collision” section in the Inspector is marked active (also Send Collision Messages), my particle system does not respond to collisions.
If I place a 3d object with collider near the particles I don’t receive any collision message.
Here is part of the written code:

private void CreateParticles()
    {
        rowCount = pointList.Count;
        particlePoints = new ParticleSystem.Particle[rowCount];     
     
        for (int i = 0; i < pointList.Count; i++)
        {
            // Convert object from list into float
            float x = (Convert.ToSingle(pointList[xColumnName]));
            float y = (Convert.ToSingle(pointList[yColumnName]));
            float z = (Convert.ToSingle(pointList[zColumnName]));         
         
            // Set point location
            particlePoints.position = new Vector3(x, y, z) * plotScale;          
         
            // Set point size
            particlePoints.startSize = particleScale;
        }
    }

private void OnParticleCollision(GameObject other)
    {
        if (other.CompareTag("Collider"))
        {
            Debug.Log("Particle collided with: " + other.name);
        }
    }

This is the Job System forum which is unrelated to particles or physics.

It seems you want the Scripting forum so I’ll move it there.

NOTE: Here’s how to post code on the forums: Using code tags properly

1 Like

okey, thank you so much!