2 particle questions

I have some questions about using particle effects (well, actually is more of an issue)

1.Why is my particle effect fully black? I’m using the particle effect file from the particle example, which is grey with a texture, but in my script it is fully black.

  1. How do I make my particles disappear after a certain time? I tried changing the lifetime value of the system in the particle effect file, but that doesn’t work, and using the cleanup() function stalls the game for a second.

Thanks a bunch

1). You’re probably using lighting on the effect. Disable lighting on the particle node with effect.setLightOff().

2). I always had trouble using Panda’s built in particle cleanup. Easiest way is to set the emission rate to zero. You can do this by using:

for p in effect.getParticlesList(): 
            p.setLitterSize(0)
            p.setLitterSpread(0)

It’ll probably make your life easier if you create a wrapper for particle systems to make them run how you expect. My wrapper has a “stop” function which sets emission rate to zero, and a “start” which restores the rate. You can then set an effect to stop by using taskMgr.doMethodLater(). I’m sure my method of handling it isn’t particulary efficient, but I’ve never had an easy time with particle systems.

Awesome, works perfectly, thanks a bunch