Photons icon indicating copy to clipboard operation
Photons copied to clipboard

Restarting a particle system should be more automated

Open insominx opened this issue 9 years ago • 1 comments
trafficstars

It is common to reuse particle systems for things like impact puffs from a gunshots hitting something. There should be an easy way (maybe 1 line of code) way to do this.

Here's how I'm currently accomplishing this:

function onMouseDown() {

    // Restarting particles is very clunky...

    if ( smokeSystem.isActive ) {

        smokeSystem.liveParticleArray.forEach( function( particle ) {
            smokeSystem.resetParticle( particle );
        } );

        smokeSystem.emitting = false;

    }

    if ( !smokeSystem.emitting || !smokeSystem.isActive ) {

        smokeSystem.emitting = true;
        smokeSystem.age = 0;
        smokeSystem.timeSinceLastEmit = 0;

        smokeSystem.activate();         

    }

}

Is there a better way that I'm missing? one-shot-replay.zip

insominx avatar Mar 18 '16 18:03 insominx

Actually there is not a better way (right now), and there definitely should be. I haven't actually had a chance to do much experimenting with release-at-once systems, so there's definitely room for improvement. I suppose we need a way to to specify whether or not we want a single release, or repeated release, and an easier way to reset the system.

mkkellogg avatar Mar 18 '16 19:03 mkkellogg