- Home /
IgnoreCollision with Particle System
Is it possible to IgnoreCollision between a Rigidbody and a ParticleSystem?
Or anything I can do after I detect the collision that I want to ignore?
PS: Like in IgnoreCollision() I need the case that the Particles and the Rigidbody don't collide at all physically.
(I know that I can specify Layers to collide. But the Players are colliding with their own particle system(Gun Effect) and if I disable the collision using Layer, there are a lot of other Players and the Gun Effect is not colliding with them too (which makes the particle system affectless and pointless.)
I need to IgnoreCollision between each ParticleSystem and its own parent)
Answer by highpockets · Apr 06, 2019 at 10:13 PM
You could put the particle system game object as a variable on your player script and when:
void OnCollisionEnter(Collider other){
if(other.gameObject != particleSystem){
// you just ignored the child particle system
}
Thanks but in that case the collision still occurs physically. I already ignore it on the script side. I should add "physically" to the question. Like in IgnoreCollision(parameter1, parameter2) two specified parameters does not collide at all. But that function doesn't work with Particles.
You also state:
“Or anything I can do after I detect the collision that I want to ignore? ”
In your question..
Check out Physics.IgnoreCollision:
https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html
Although it states “Note that IgnoreCollision will reset the trigger state of affected colliders, so you might receive OnTriggerExit and OnTriggerEnter messages in response to calling this. IgnoreCollision has a few limitations:” So there still is detection of the collision. I’m guessing you want to do this so as to not have unnecessary calculations because the code I provided should work for what you need. The thing is, even if you take the collider off of the particle system and try to do it manually, there will have to be checks so as not to affect the player that emits the particles.
I'm trying to ignore the collision because the gun effect gets effected by the player who shoot it. Calculations are not a concern. Gun should collide(by collision I mean doesn't go through. Stop at the surface of the object) only when it hits enemies(which are other Players). But it collides with the player who shoots the gun(as if it hit an enemy). As a result of this: The gun doesn't go through the player who shoot it. Because I can't find a way to ignore this, I'm shooting the gun starting far from the player's collider. But that makes a big gap between the player and the gun effect. If I could ignore the collision physically or if I could reset/revert the collision before just it starts to occur physically the problem will be gone.
Your answer
Follow this Question
Related Questions
Using Particles with Collision 2 Answers
How to have a particle system Ignore collision with objects 1 Answer
Can I make uniform emission for Particle System? 2 Answers
How to detect when and where a particle hits a surface? 4 Answers
Get sprite id or grid x and y from particle on trigger. 0 Answers