2009
NOTE It is especially important to assign nodes and tracks to variables with the
corresponding buttons when using XRef scenes and objects.
Procedures
Example: To keep an object centered relative to other objects in the scene
during an animation:
1 Name the object that should remain centered foo and assign a Script
controller to its Position track.
2 Enter foo in the Name field and click Create.
The new variable is automatically added to the Variables list.
3 With the variable highlighted, click Assign Node.
The Track View Pick dialog opens, listing the contents of your scene.
4 Expand the Objects hierarchy until you locate foo. Highlight it and click
OK.
The foo node is assigned to your variable.
5 Enter the following script in the Script Controller dialog's Expression
window:
local pos=[0,0,0]
for o in objects where o != foo do
pos += o.pos
pos / (objects.count - 1)
This script computes the average position of all objects, except the current
one (written as foo here) by setting up a local, iterating over all objects
except foo, accumulating a total position vector, and computing the
average in the last line, which is the final result of the script.
3250 | Chapter 15 Animation