Set particle Lifespan

 
 
 

You can give particles and nParticles a lifespan to make them disappear from the scene after they reach a specified age. Though you can give a lifespan to particles or nParticles you’ve created with the Particle Tool or nParticle Tool, lifespan is typically used with emitted particles. For example, you can use lifespan to fade out emitted smoke or fire. You can set the lifespan for all the particles or on a per-particle basis.

Note

The following sections on particle lifespan are also applicable to nParticle objects and the nParticleShape node Attribute Editor.

All particle and nParticle objects have the following attributes:

Per-object lifespan attributes

Per-particle lifespan attributes

These attributes are used together to control lifespan.

Set per-object lifespan

Setting per-object lifespan assigns the same lifespan to all particles in the particle object. You can make particles live forever or make all particles die at the same age.

To make particles live forever

  1. Select the particle object and display the Attribute Editor.
  2. In the Lifespan Attributes section, set Lifespan Mode to Live forever.

To make particles die at the same age

  1. Select the particle object and display the Attribute Editor.
  2. In the Lifespan Attributes section, set Lifespan Mode to Constant.
  3. Set Lifespan to the desired value.

    The Lifespan value is the number of seconds that the particle object exists after it is created. A particle object you create with the Particle Tool is considered to be created immediately at the beginning of the first frame of the scene. An emitter particle is created when it is emitted. The default value of 1 makes the particle object disappear after one second.

    Tip

    If your particles aren’t dying, make sure you haven’t set Lifespan to a large number—one that exceeds the time duration of the scene’s Time Slider.

Set per-particle lifespan

Setting per-particle lifespan assigns different lifespans to each particle in the particle object. You can make particles die at random ages, assign a lifespan to individual particles, or use an expression to control the lifespan.

To make particles die at random ages

  1. Select the particle object and display the Attribute Editor.
  2. In the Lifespan Attributes section, set Lifespan Mode to Random range.
  3. Set Lifespan to the desired value.
  4. Set Lifespan Random to the desired value.

    The lifespan is uniformly distributed with Lifespan as the mean and Lifespan Random as the width of the distribution.

    For example, if Lifespan is 3 and Lifespan Random is 2, then each particle will have a lifespan between 2 and 4.

    The random number stream for Random range lifespan mode is maintained inside the particle object and is automatically reseeded when you rewind. You do not have to reseed it yourself.

  5. If you want to change the random number stream for random range lifespan, specify a value for General Seed.

    Normally, you don’t need to change this value. If you want two identical looking particle objects, you can set this value to match the other particle object’s General Seed value.

    Note

    While Lifespan = 4, Lifespan Random = 2 is mathematically equivalent to the expression $lifespanPP = 3 + rand(2);, these two methods of setting lifespan will not give identical results because the random number streams are different.

To control lifespan of individual particles

  1. Select the particle object and display the Attribute Editor.
  2. In the Lifespan Attributes section, set Lifespan Mode to lifespanPP only.
  3. In the Per Particle (Array) Attributes section, right-click the Lifespan PP data box and select Component Editor from the pop-up menu.
  4. Click (the Select by Component Type icon).
  5. In the workspace, select the specific particles you want to edit, and click Load Components.

    See Set particle attributes with the Component Editor for more information on using the Component Editor.

  6. Click the entry box for lifespanPP and enter a value.

To use expressions to control lifespan

  1. Select the particle object and display the Attribute Editor.
  2. In the Lifespan Attributes section, set Lifespan Mode to lifespanPP only.
  3. In the Per Particle (Array) Attributes section, Right-click the Lifespan PP data box and select Creation Expression or Runtime Expression (before or after dynamics calculation) from the pop-up menu.
  4. Create a creation or runtime expression to assign a unique value to each particle (see Expressions).

    Note that you cannot key this attribute or other per particle attributes.

How lifespan is determined

A read-only per-particle attribute called finalLifespanPP stores the final result of lifespan computations no matter what mode you are using. The particle shape uses finalLifespanPP to kill particles and to drive ramps.

You cannot set the value of finalLifespanPP yourself in any way (for example, with an expression, ramp, or component editor). Like age, it is an attribute the particle shape computes for you. But you can read its value (but not assign its value) in an expression.

In Random range mode, lifespans are determined for each particle when it is born, and are stored in finalLifespanPP. If you change Lifespan or Lifespan Random, it affects new particles but does not affect particles that are already born. If you rewind and re-play, all particles are affected.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License