2009

Table Of Contents
Using runtime expressions
There is one other type of expression you can create for a particle object (shape
node)a runtime expression. By default, a runtime expression executes each
frame during playback. A runtime expression does not execute when you go
to the start time (or at the time in which a particle is emitted).
Youll often create both types of expressions for a particle objecta creation
expression that initializes an attribute value in the first frame, and a runtime
expression that controls the attribute value in subsequent frames.
The following steps show how to create a runtime expression to change particle
color during playback.
To create a runtime expression
1 In the Per Particle (Array) Attributes section of the Attribute Editor,
right-click the rgbPP box and select Runtime Before Dynamics Expression
from the pop-up menu.
2 Enter this runtime expression:
BubblesShape.rgbPP = sphrand(1);
3 Click the Create button to compile the expression.
4 Play the animation.
The particles flicker in random colors as the animation plays back. The
runtime expression controls the rgbPP attribute during playback. Because
rgbPP is a per particle attribute, the runtime expression executes for each
particle in the object for each frame. For each particle, the expression
assigns the rgbPP attribute the output from the execution of the sphrand
function with an argument of 1. The sphrand function is one of Mayas
many built-in mathematical functions that are useful in expressions.
The sphrand function with an argument of 1 assigns each particles rgbPP
color a random vector. The vector represents a random point in a spherical
Using runtime expressions | 587