2010

Table Of Contents
NOTE You can use only one creation and one runtime expression per particle
object (shape node) in your scene. To control multiple attributes of a single
particle object, you must do so within one creation expression and one
runtime expression. You cant create a separate expression for each attribute
as you can for other types of objects. You therefore dont need to select an
attribute from the Expression Editors Attributes list.
Modifying runtime expressions
You might have trouble seeing the color of a particle in any instant because
the color changes so quickly. You can slow the change of colors to create a
flashing Christmas light effect. The following steps make the particles change
colors every second of animation.
To adjust the timing of the change of color
1 Change the runtime expression to this:
if ((frame % 24) == 0)
BubblesShape.rgbPP = sphrand(1);
This expression uses the modulus operator (%) to control when the rgbPP
attribute of the particles receives a random color. The modulus operator
returns the remainder after division. For example, 24 divided by 24 returns
0, but 25 divided by 24 returns 1. (Dividing 25 by 24 equals 1 with a
remainder of 1.)
If the value of frame divided by 24 is equal to any number with a
remainder of 0, the assignment to BubblesShape.rgbPP occurs. In other
words, the assignment occurs when frame equals 24, 48, 72, and so on.
At an animation rate of 24 frames/second, the assignment happens once
each second.
The == symbols mean is equal to. In conditional statements, be careful
to type == rather than =. The = symbol means assign the value to.
2 Rewind and play the animation again.
When you go to the start time, the particles turn red because the creation
expression executes. When the animation plays, the particles receive a
random color once each second.
648 | Chapter 12 Expressions