Cloning Particle System and Discarding texture

Hi there,

I am working on optimzing my game and noticed a lot of duplicate textures getting created everytime I clone a particle system. So I tried the following code to remove the texture from hierarchy and while the texture gets disposed fine., the particle system is not taking the sprites I intended. I have also tried creating a new particle system entirely but still getting some weird results. Any help is appreciated.

 const torchFireParticle = this._torchFireParticle.clone(`Fx_torchFire_${mesh.name}`, mesh);
    torchFireParticle.particleTexture.dispose();
    torchFireParticle.particleTexture = this._torchFireParticle.particleTexture;
    torchFireParticle.emitter = mesh;

Hello and welcome!

Do you mind reproducing the issue in the Playground?

Sure. I will do it soon and let you know

Ohh so it looks like I had to change the sprite start and end ids as they were not getting set properly after cloning. I set it up in playground and it was looking weird the same way it did after cloning. Just changed the sprite ids and it worked. Thanks and sorry to bother you. One thing I dit not understand though was how did it look fine earlier when I was not disposing the texture.

1 Like