Particle lifetime units?

I was wondering what units the particle lifetime is in…
Is it in milliseconds? or frames?

Hmm checking the source code, particleSystem.updateSpeed is added to the particle’s age each frame (adjusted for frame rate). So then I suppose the units of the particle’s min and max life time are based on the value you set updateSpeed to.

For example using 0.01, the default updateSpeed, 0.01 is added to the particle’s age once every 16.67 ms, so the units would be 16.67 / 0.01 = 1667 ms = 1.667 seconds. So then a lifetime of 10 would last about 10 * 1.667 seconds = 16.67 seconds.

And a quick test seems to confirm this calculation, as the below particle system with min and max lifetime 10 and default updateSpeed 0.01 spawns a new particle every 17 seconds approximately. :slight_smile:

EDIT: ps, so then solving for lifetime leads to the below code you can use to set the lifetime properties based on how many seconds you want the particles to last. :beers:

particleSystem.minLifeTime = LIFE_TIME_IN_SECONDS * 60 * particleSystem.updateSpeed;
particleSystem.maxLifeTime = particleSystem.minLifeTime;
6 Likes

Thanks, I was just reading up and using this in my own code!