Textures created by particle system

Hi there,

I’m using the particle system to create some fancy explosions in my RTS game.

I noticed that each time I create a particle system, Babylon creates two textures.

image

It’s the “no name” and the flare textures.

I create the particle system using:

ParticleHelper.CreateDefault(position, 50, this.scene, false);

As there will be a LOT of explosions during the game, I’d like to get rid of those extra textures. :slight_smile:

What’s the best way to accomplish that?

Cheers,
Jeroen

Best way to obliterate something out of your scene is to use the “.dispose()” method.

Perhaps in your example, after the particles die, you could do a quick search for those texture names and then dispose of the textures?

1 Like

Hi guys. Jeroen… just in case useful, we have manualEmitCount (used instead-of emitRate) that is helpful to make multiple explosions… using only one particleSystem.

Here’s an example: https://playground.babylonjs.com/#36UHXZ#48

See line 91 emitRate? Disabled. :slight_smile:

See line 113? Set particleSystem emitter to be a vector3 (cool, huh? It can also be a mesh.)

Now let’s look at the renderLoop… lines 121 and 122… I put the vector3 emitter into an “X-Z orbit animation”… right? In your game… you would have a function… makeExplosion(where). I’m just using an orbiting where for an example.

Now onto lines 123-126… every 50th renderLoop… I set the .manualEmitCount = 1000; POOM! Explosion of 1000 particles… and then particleSystem goes (back-) to sleep… awaiting the NEXT setting of .manualEmitCount to ANY value greater than 0.

AND, you can change ANY particleSystem parameters… just-before setting .manualEmitCount explosions (within your explosion-maker function, for example). Soooooo… a fancy SINGLE PS explosion-maker function… might be like this…

var makeExplosion = function(whichPS, whereEmit, size, color, direction, power, etc, etc) { massive code }

Your custom make-explosion function… can make all sorts of adjustments to ALL the properties on whichPS… and then LAST THING in the function… set the .manualEmitCount and return. POOM.

Jeroen’s Variable Particle Explosion Generator v1.0. “Getting the most… from a single particleSystem” :slight_smile:

Just an idea. Might help your issue, might not. :slight_smile: Here’s a search for more playgrounds that use .manualEmitCount.

Ignore the customUpdater in the #48 playground - used to make sparticles (sparkly particles). Demented Wingnut experiments of old. :slight_smile:

1 Like

Thanks guys, that’s very helpful!

Wingnut: that is, indeed, what I am aiming for: the ability to generate multiple sorts of explosions using a single particle emiter. I’ll be sure to check out your examples - thanks a bunch!

In case anyone is interested, here’s a little video on Linkedin showing the first little test with explosions:

1 Like