- Home /
Find particle by tag and deactivate
In my game I have several checkpoints each with a particle emitter. I want to disable all the particles and then enable the current one. Every particle emitter has the same tag, which I want to use to find and deactivate all - then enable the current one. But this code isn't working:
checkpointParticles = GameObject.FindGameObjectsWithTag("CheckpointParticles");
for (var checkpointParticle in checkpointParticles){
particleSystemToDeactivate = checkpointParticle.GetComponent(ParticleSystem);
particleSystemToDeactivate.enableEmission = false;
}
The error I get is: There is no 'ParticleSystem' attached to the "SparkleParticles" game object, but a script is trying to access it.
But I know that this isn't true. The tagged object "SparkleParticles" has an Ellipsoid particle Emitter, a particle animator and a particle renderer.
Answer by robusto · Jun 14, 2014 at 01:39 PM
You are using the old, legacy particle system. The new particle system (shuriken) is the GetComponent(ParticleSystem). The legacy particle system has 3 different components: GetComponent(ParticleRenderer), GetComponent(ParticleEmitter), and GetComponent(ParticleAnimator).
http://docs.unity3d.com/ScriptReference/ParticleAnimator.html
http://docs.unity3d.com/ScriptReference/ParticleEmitter.html
http://docs.unity3d.com/ScriptReference/ParticleRenderer.html
Oh crap I didn't realise! The particles were standard assets that came included in Unity so I thought they were they newest! Dammit!
Thanks :-D
Your answer
![](https://koobas.hobune.stream/wayback/20220613151519im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I set the position of a newly emitted particle in a local enabled particleSystem? 1 Answer
Unityscript - Using "as" to cast for GetComponentsInChildren returns empty array 1 Answer
Particle System Appear Where Clicked 1 Answer
Setting Scroll View Width GUILayout 1 Answer
Dectect collision, but not actually stop the object? 1 Answer