- Home /
How to specify particle collision detection
I am using multiple particle systems in my game, and I would like to create a different trigger for each.
However, it seems I can't do this without having one type of particle (for example: a flamethrower) trigger the same reaction as a different particle system (a fire hose) despite my efforts to differentiate the two.
My guess is that since both particle systems are set to "Send Collision Message" when colliding with something, that the game does not know how to differentiate the two, and as of now both my flamethrower and my fire hose set things on fire (They both send the same collision message).
I have been using the function OnParticleCollision(), is there any way to specify which particle system activates my script if they are both sending the same collision message? Is there a way to differentiate the collision messages being sent?
I have searched for answers to this problem and have not found anything, but I can't imagine I am the first to run into this issue. All help is appreciated, I am stumped. Thanks in advance!
Answer by ifurkend · Dec 11, 2018 at 04:01 AM
The code example in OnParticleCollision() script manual already states that you can use GetCollisionEvents to specify collision events from one specific Particle System. Recently I have written an Audio Playing script on Particle Collision, here is the excerpt of my code:
void OnParticleCollision (GameObject other) {
if (_collision == true) {
int numCollisionEvents = _particleSystem.GetCollisionEvents(other, collisionEvents);
for (int i = 0; i < numCollisionEvents; i++) {
PlaySound(collisionEvents[i].intersection);
}
}
}
The Particle System component with Collision module enabled for sending collision messages is assigned to the _particleSystem variable of the script.
Ah, I figured I must have missed something, I will give this a try and report back! Thank you for your response!
Well, I gave it an honest try, but after more confusion I have thrown in the towel for the night. Thank you for pointing me in the right direction, however I feel my understanding of coding is too rudimentary to solve this issue now (this is my first Unity project and I have zero prior experience with coding).
I'll fiddle around with GetCollisionEvents more, but for now I've got to take the L and call it quits. Thank you for the help, sorry I wasn't able to get back to you with a better conclusion!
Did you ever solve this? I've spent 2 days trying to work this out and I'm totally stumped.
The collision is recognised but the game object is not.
Your answer
![](https://koobas.hobune.stream/wayback/20220612183724im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to Make Particle Effects Function as a Trigger That Deals Damage 1 Answer
How to keep particles moving past an obstacle after they have collided with it? 3 Answers
how to give particle bursts their own colliders 0 Answers
Particle effects won't collide/play properly 0 Answers
How to detect which exact particle element from a particle system hit a collider? 0 Answers