Stopping multiple emitters

So, I had a problem which seems arbitrary, but is causing some nuisance for me… basically, I have a bunch of particle emitters attached to my rootNode, and I want to simultaneously turn them all off (stopping them emitting). Basically, in “pseudo”-code

[java] for(ParticleEmitter p : rootNode.getChildren()) p.killAllParticles(); [/java]

However, this really doesn’t seem to work, as getChildren() only contains spatials?

1 Like

If u put 'em all into a subnode like emitters, you could do the following:

[java]
Node emitters =new Node(“emitters”);
rootNode.attachChild(emitters);

emitters.attachChild(yourEmitter1);
emitters.attachChild(yourEmitter2);
[/java]

and if u want to kill u do

[java]
for (Spatial s:rootNode.getChild(“emitters”).getChildren())
((ParticleEmitter) s).killAllParticles();
[/java]

or you put emitters as a member into your controller

1 Like

You could recursivle go trough the scenegraph and test
if spatial instance of node
-> do for each child
if spatial instance of emmiter
-> kill

1 Like

This is what the SceneGraphVisitor is for.

1 Like