Explosion Effects

What’s the proper way to do explosion effects?



I can’t seem to figure out a clean way to have the particles explode and then dissapear. Right now the particles keep coming back to life. The only method I see that handles respawing is forceRespawn which brings everything back to life and I want to keep everything dead



:wink:



Thanks!

yeah, use .setRepeatType(Controller.RT_CLAMP);

It might be useful to see a code section… Here’s how I make explosions in FurBallz (minus the setting of texture, alpha and zstates of course):


        ParticleManager explosion = new ParticleManager(80, display.getRenderer().getCamera());
        explosion.setGravityForce(new Vector3f(0.0f, 0.0f, 0.0f));
        explosion.setEmissionDirection(new Vector3f(0.0f, 1.0f, 0.0f));
        explosion.setEmissionMaximumAngle(3.1415927f);
        explosion.setSpeed(0.4f);
        explosion.setParticlesMinimumLifeTime(600.0f);
        explosion.setStartSize(2.0f);
        explosion.setEndSize(5.0f);
        explosion.setStartColor(new ColorRGBA(1.0f, 0.312f, 0.121f, 1.0f));
        explosion.setEndColor(new ColorRGBA(1.0f, 0.24313726f, 0.03137255f, 0.0f));
        explosion.setRandomMod(0.0f);
        explosion.setControlFlow(false);
        explosion.setInitialVelocity(0.02f);
        explosion.setParticleSpinSpeed(0.0f);
        explosion.setRepeatType(Controller.RT_CLAMP);
        explosion.warmUp(1000);



Then I call this to set off the boom:

        explosion.forceRespawn();



Play with the params and LocalScale to get the exact effect you are looking for.

Thank you very much Renase!

Right now I’m creating my explosion effect and attaching it to the scene when a bullet collides with the ship.



This of course results in a pretty big slow down at the moment of impact.



What’s a good way around this? I know I can create the effect on startup so it’s all ready to go when I want to fire it off but what if you want to have multiple explosions going off at the same time? If you create just one explosion effect on start up then you can only have one explosion at a time (or am I wrong there?).



There’s no good way to guess how many explosion effects you need to create either as there isn’t a reliable way to tell what the maximum number of simultaenous explosions might be.

In FurBallz I have a factory that prebuilds 3-4 explosions and reuses those… If they are all unavailable (check isAlive()) at the time of request, I create another one… I suppose I could create a new one in a more proactive way… anyhow, this all seems to work fine for my use.

Okay …

That sounds like it’ll work. Thanks for all your help today. I should probably send you a check or something for consulting fees heh.

Hehe, there’s a donate to jME link on the main page… :wink: j/k hth!

I know! I’ve donated :slight_smile: I’ll have to make another one soon I think haha. Maybe with the release of 0.9 :wink: