pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
784 stars 124 forks source link

particle systems run slower after migration from 4.3.x to 5.0.7 #183

Closed codingchili closed 1 year ago

codingchili commented 1 year ago

Hello,

I'm having an issue after upgrading from 4.3.x to 5.0.7 where all particle systems runs slower than before (emission, movement etc). Approximately 50 times slower. I can reproduce this by downloading the 'flame' emitter from the interactive editor and inserting it into my game using pixi 6.5.1 with upgradeConfig.

Any idea what could have changed that would cause this?

andrewstart commented 1 year ago

Just as a sanity check, could you try version 5.0.5 and see what happens? Also, are you using the autoUpdate property, or are you calling Emitter.update() on your own?

codingchili commented 1 year ago

ah many thanks, I'm not sure why the particle system was playing 50x slower yesterday.. today it's playing way too fast instead.

anyways, I'm not using the PIXI.ticker.shared - calling emitter.update(deltaSec) from my RAF loop. I see that autoUpdate defaults to false, which should be fine for me. BUT when I check the property at runtime autoUpdate was set to true.

I'm using the playOnceAndDestroy method, I'm not sure why it sets autoUpdate to true? this seems to override any autoUpdate property set in the config and the default value of false,

playOnceAndDestroy(callback) {
            this.autoUpdate = true;
            this.emit = true;
            this._destroyWhenComplete = true;
            this._completeCallback = callback;
        }

And the reason (at least for particle systems playing too fast) was that autoUpdate modifies my delta in the update method,

if (this._autoUpdate) {
    delta = ticker.elapsedMS * 0.001;
}

Particles are looking great and working as expected again when I set autoUpdate to false after calling playOnceAndDestroy. :)

andrewstart commented 1 year ago

Yeah, playOnceAndDestroy() is intended to be used with autoUpdate as the simple way of doing things. Outside of that, you can start an emitter with emitter.emit = true or emitter.playOnce(), call emitter.update() yourself and then destroy or reuse the emitter when it is complete.

codingchili commented 1 year ago

Thanks, it's all in the docs too :)