Change the expression to this:
Cube.Pitch_X = time * 25;
Cube.Yaw_Y = Cube.Pitch_X;
Cube.Roll_Z = Cube.Pitch_X;
Now the sphere increases the value of its position channel twice as fast of the previous expression.
Because in the previous expression we linked the Cube.Yaw_Y and the Cube.Roll_Z values to the Cube.Pitch_X channel, as we change the X rotation factor to time multiplied by 25, the other rotation channels follow suit.
You could do the same thing by inserting a variable in the expression.
Using a variable
Change the expression to this:
spin = time * 25;
Cube.Pitch_X = spin;
Cube.Yaw_Y = spin;
Cube.Roll_Z = spin;
This expression creates the same result as the previous example. The first statement in this expression defines a variable named spin; this variable is used as a container to hold a value that we assign to it (time * 25 in this example). As the animation plays, time increases, and along with it the value of the variable, spin, increases by the value of time times 25.
The next statements are there to assign the contents of the variable, spin, to the 3 rotation channels. Since they each receive the same, non-modified data from spin, the Cube rotates uniformly around each axis.
To change the rate of the rotation change in Cube you now only have to modify the spin variable. All rotation channels will now get the updated value.
Summary
In this section, you learned how to:
- use an expression to link multiple animation channels of an object
- define and use a variable in an expression
- alter a single statement and have that alteration be reflected in other statements without having to manually change those other statements.
|