- Home /
Programmatically Enable/Disable Shurikan Particle Collision Module
I'm expecting there to be a:
myParticleSystem.GetComponent<ParticleSystem>().CollisionModule.Enabled = false;
but unfortunately there isn't, in fact, I can't seem to programmatically access any of the particle modules. So far the only way I can enable/disable collision is by manually clicking the Collision Module > Enabled property in the inspector. Essentially what I'm looking for is to have an option for the player to enable/disable particle collision, for performance reasons
I've considered using two different particle systems, the only difference being one has the Collision Module enabled, and the other doesn't. That however seems kind of ridiculous, considering there is a checkbox for it right there on the ParticleSystem Module......
Any ideas?
Thanks!
Answer by roberto_sc · Feb 20, 2017 at 01:46 AM
Do this:
ps = GetComponent<ParticleSystem>();
var collision = ps.collision;
collision.enabled = false;
Like stated in the documentation.
Notice that that is different than doing this:
ps.collision.enabled = false;
Answer by Sundar · Nov 10, 2013 at 06:00 PM
Did you try this
myParticleSystem.GetComponent<CollisionModule>().Enabled = false;
I don't believe there is a Collision$$anonymous$$odule class to do that. I may be mistaken, bit I thought I've tried that.
Answer by IgorIvanov · May 08, 2014 at 10:31 AM
So badly... Unfortunately there is no any way to get CollisionModule (and others) from script that will be compiled. For example, I need in planes for CollisionModule to restrict my particle rays PROGRAMMATICALY!
Your answer
Follow this Question
Related Questions
Spawning particles inside of collider 0 Answers
How to keep particles moving past an obstacle after they have collided with it? 3 Answers
How to detect which exact particle element from a particle system hit a collider? 0 Answers
ParticleSystem collision checking. 2 Answers
Particle collision radius origin is offset to the left. How can I make it centered? 1 Answer