“Expressions for Dummies”
Expressions is the kind of topic that makes many animators say “That’s way too complicated for me!” However, expressions can be surprisingly easy to understand, once you get your feet wet. The best way to understand how to use expressions is to apply some and see what they do ... so let’s go!
1 of 11
Tutorial • “Expressionsfor Dummies”
Jumping into Expressions
To understand expressions better, try the following simple exercises. Once you’re comfortable with the process and the expression editor, you can go on to more complicated expressions and setups. Setting Up a Constant Expression 1. Get a primitive sphere (or something equally as exciting). 2. Select the sphere and press Ctrl+k (this opens the sphere’sLocal Transform property editor). 3. Right-click on the animation icon (green box) of the local Position Y parameter and choose Set Expression. 4. In the expression editor, enter the value of 5 in the expression pane and click the Apply button, but keep the expression editor open to take a peek at what you just did: - At the top of the expression editor is the parameter (sphere.kine.local.posy) thatyou’ve set to be equal to 5. - Notice that the Position Y animation icon has the letter “C” in it to indicate that it’s a constant expression (where the value is a number).
- An Expression page is added to the Local Transform property editor so that you can easily edit this expression later, including adding comments.
5. Close the expression editor.
2 of 11
Tutorial • “Expressions forDummies”
Congratulations, you’ve just set the simplest kind of expression known to humankind! The sphere is now fixed at 5 units on its Y axis. You won’t be able to translate it anywhere else in this direction, but you can still move it in X and Z. Trying It Another Way Here’s another way of creating a constant expression: 1. Get yet another sphere and set its Translation Y value to 5. 2.Again, press Ctrl+k, right-click on the Position Y parameter’s animation icon, and choose Set Expression. Notice the expression editor opens with the value of 5 already in it. You’ve just created a constant expression the same as in the first exercise. Creating a Simple Equivalency Expression You can also easily create simple A = B expressions between parameters: 1. Open a new scene and get a sphereand a null. 2. Translate the null in X a little to offset it from the origin and the sphere. 3. Select the sphere and press Ctrl+k to open its Local Transform property editor. Lock this property editor to keep it open (click its keyhole icon). 4. Select the null and press Ctrl+k to open a Local Transform property editor for it.
3 of 11
Tutorial • “Expressions for Dummies”
5. Drag and dropthe animation icon for the null’s Position X parameter to the sphere’s Position X parameter in the other property editor.
- The expression editor opens with the affected parameter, sphere.kine.local.posx. Its expression below is null.kine.local.posx, meaning that the sphere takes its Position X value from the null’s Position X value. - The sphere’s animation icon for the Position X parameternow has an equal sign (=) in it to indicate the expression. If there would have been animation on the animation icon being dragged, the animation would have simply been copied to the other parameter, but no expression would have been set. 6. Test the expression by translating the null in X: the sphere should follow in X. 7. Close the expression editor and the two property editors to keep the sceneuncluttered. One More Time Here’s another way to create an equivalency expression: 1. Select the sphere, press Ctrl+k, right-click on the animation icon for Position Y, and choose Set Expression.
4 of 11
Tutorial • “Expressions for Dummies”
2. In the expression editor, type null.kine.local.posx in the white expression pane below and click the Apply button. Now as the null is translated...