In this lesson you learned how to:
When you write expressions, it is common to assign the built-in time variable to an attribute so the attribute value predictably increases as the animation plays. It’s also useful to link an attribute’s value to the value of another attribute, such as setting the ball’s scale Y and Z attributes to equal the scale X value.
Your expressions can control multiple attributes of the same object or of multiple objects. Alternatively, you can write a single expression for each attribute or object.
For more information on the various mathematical operators that are possible with expressions, refer to the Maya Help.
Although not shown in the lessons, you can decrease an attribute value during playback by subtracting time from some number. Example:
Ball.scaleY = 3 - time;
This decreases the value of Ball’s scaleY attribute for the first three seconds of playback.
When you use the predefined time variable, note the animation start frame value. The lessons in this chapter use a start time of 0. In your work, you might create an animation with a start time of 1. With Maya’s default frame rate of 24 frames per second, time is 0.0417 at frame 1.
Because of this small time offset from 0, the prior lesson would have required more steps and instructions to work with frame 1 as the start time. For instance, suppose you use following expression with the start time at 1.
Ball.scaleY = time + 1;
If you go to the start time, the expression sets the initial value of Ball’s scaleY attribute to time + 1, which equals 0.0417 + 1, or 1.0417. Because Ball’s scaleY attribute was 1 when you created it, going to the start time sets scaleY to a value 0.0417 larger than its initial value.
This discrepancy means the Ball scaleY is larger than its scaleX and scaleZ attributes in the first frame of the animation. Although the difference is minor in this example, other cases might be more significant.
To start your animation at frame 1 and get the same result as the example, you can subtract 0.0417 from the attribute:
Ball.scaleY = (time - 0.0417) + 1;
When you go to the start time, the expression sets Ball’s scaleY value to (0.0417 - 0.0417) + 1. This equals 1, its original scaleY value.
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License