OnParticleCollision() on parent script, for a child particle system?

I’m working on a turret asset script update, and trying to add a particle turret to the list of features.

I have the script on the parent, and a child game object with the particle system. I put OnParticleCollision() in the parent script, but its not detecting collision of the particle system, because its on a child gameobject.

It only works if I place the script with OnParticleCollision() on the gameobject with the particle system, doesn’t work if its a on a parent. I assumed it would work, because that’s how regular compound colliders work.

The turret script has to be on the parent, and the particle collider will in most cases have to be on a child. And for simplicity’s sake, I’d prefer to avoid splitting the script into two pieces just so I can have a few lines of code about particle collision, somewhere down the hierarchy on one of the child gameobjects. So can this be done somehow? Keeping the script on the parent, and detecting collisions of the child particle system?

PS. Alternatively maybe being able to adjust the particle start position through script would be good too, then the particle system won’t have to be on the child game object, but I don’t see that option in the documentation.

This can help:

Use public void Play(bool withChildren = true);
on a parent gameobject to play a child particle system
but I have tested it and he give me errors :-(, maybe you have more luck…

I don’t believe there’s a workaround without splitting the work between the parent and child objects.

Each OnParticleCollision() is for the collider of that GameObject or the Particle System that script is attached to. So like you suspected, the OnParticleCollision() in the parent will be trying to get collision information for the parent object without caring about its child object.

Is there a reason you want to call OnParticleCollision() on the child object? Can it not be called on the object that the particles will be colliding into?