Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use lifetime to visually disable/enable particle systems #52

wants to merge 1 commit into
base: master


Copy link

danilko commented Nov 26, 2018

Update to use lifetime to visually disable/enable particle systems

There is currently two ways in armory for dynamically affect particle systems (sorry if there other ways that I do not realize):
Use speed parameter
This actually "stop" the particle system, however, the particle is still there in air

Limit the lifetime of an article object and re - spawn it
This is doable, but seem to be a very expensive solution (but maybe is wrong) if the particle system is intend to be re - cycle through out the system, for example, car drift smoke, or weapon firing.

So this patch is try to introduce a third approach, instead of spawning a complete new object, it set the lifetime of each particle to be 0, so all of them will disappear immediately at that exact disable comment.

It may not be the most ideal approach (as the ideal approach will some how let all the current particles finish, and then not spawn new one). But seem to be more easier to manage then spawning a new object with new particle system every time.

Implement result can be found at here (where the brake moment used this mechanism):

For each tire object, there is an object attachment, during brake at high speed, will produce the particle and disable otherwise

       var mo = cast(object, iron.object.MeshObject);
       var psys = mo.particleSystems.length > 0 ? mo.particleSystems[0] : null;
       if (psys == null) mo.particleOwner.particleSystems[0];
        // If it it is break, or on dirt, enable it, otherwise disable effect
       if (isBrakeEffect == true)
… - enable back to default value to re - enable the particle system again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.