- Home /
Particle Collisions not triggering OnParticleCollision
I'm trying to create a particle system that will collide with other objects, and having no luck at all. I have defined a particle system, and set it to use the world collider, to collide with all objects, and to send collision messages. But it never triggers any messages when very clearly passing through another collider.
The other object has a Capsule Collider, set up as a trigger collider, and is working properly with other game object collisions. I have this method on the script the other object is running:
void OnParticleCollision(GameObject other) {
Debug.Log ("Particle Collision!");
}
But I never get a debug log entry.
I've read the documentation for this already, and tried several variations of options and configuration, but nothing seems to cause the particles to collide.
If you need other information, or have any questions let me know. I'm getting Unity set up on a computer at work so I should be able to provide screenshots of my object setup soon.
The object for the spaceship, which contains the particle emitter:
The object for the asteroids (Objects that particles are failing to collide with)
The particle emitter itself: https://www.dropbox.com/s/dgmge7xn2yk6noq/ship-shields.png?dl=0 (Can't attach 3rd image)
I have attempted changing the collider to not be a trigger, I've charged the particles from local to global simulation space, I've tried putting the particle system on the parent ship object instead of on a child, I've fiddled with all of the collision detection settings on both the asteroids and the particle system. Nothing seems to change the collision behavior of the particles at all.
Answer by Utoxin · Apr 09, 2015 at 04:28 AM
Well, while waiting for this to be approved by the mods yesterday I ended up solving it, although it took a while.
There were two main issues.
The particles needed to be meshes, not billboards. I settled on using Quad meshes for them, since I just need effectively 2D sprites.
The asteroid collider needed to NOT be a trigger collider. I was worried this would break other stuff, since I thought it was needed, but it turned out it was just fine.
With those two things fixed, the shields now behave exactly how I wanted them to.
Answer by krisventure · Feb 16, 2017 at 01:58 PM
Apparently, the issue described by @Utoxin has been fixed ever since. Now you can get billboards, not only meshes, to trigger OnParticleCollision(). My Particle System Collision settings are shown in the screenshot below, it works fine with billboards.
And the code in any of the scripts attached to the target objects hit by the particles:
void OnParticleCollision(GameObject particleHolderObject) {
if (particleHolderObject.name == "MagicBullets") {
// your code
}
}
Note that it makes a huge difference that you don't need to waste your resources on meshes and the collision accuracy seemed to be more precise as I could allow much more particles with billboards than with meshes. More particles, more collisions, I guess that's why I got better detection like that.
wow, thanks so much, I was almost there, but needed to check "Send Collision $$anonymous$$essages". Without that screenshot, I would have never found that :D
Answer by insoluzioni · May 14, 2020 at 04:14 AM
This is old, but my problem was that I forgot to check "Send Collision Messages" in the Collision Module of the Particle System inspector. Also, I can confirm that billboards will trigger the event as well.
Answer by ArneSnackaert · Dec 28, 2021 at 03:09 PM
If anyone coming across this. I had send collision enabled. I had colliders on my objects as well as rigidbodies and it still didn't work. You have to make sure the script is on the same gameobject as the particle system.