You can make Balloon rise after it inflates by adding another if statement to the expression.
To add an if statement to the expression
if (time < 2)
Balloon.scaleY = time;
if (time >= 2)
Balloon.translateY = time;
Balloon inflates for two seconds. After two seconds, Balloon stops inflating and its position skips from a Y-axis position of 0 to 2. You’ll eliminate the motion skip in a later step.
The new if statement increases the translateY position of Balloon after the animation time rises above two seconds. The >= symbols mean greater than or equal to. Whenever time is greater than or equal to 2, the expression assigns Balloon’s translateY the value of time. The translateY value therefore increases for the rest of your animation’s playback range.
Notice that a semicolon ends each statement for a particular condition. Forgetting a semicolon after each statement causes a syntax error, and the changes you’ve made to the expression won’t take effect.
Balloon doesn’t return to the origin because the expression doesn’t assign Balloon a starting point for the beginning of the animation.
if (time < 2)
Balloon.translateY = 0;
if (time < 2)
Balloon.scaleY = time;
if (time >= 2)
Balloon.translateY = time;
The new first statement sets Balloon.translateY to 0 whenever time is less than 2.
Note that you can put the three statements in any order in this example. When Maya plays each frame, it executes each statement in the expression in the order listed. In this example, the statements work independently, so their order doesn’t matter.
We put the statements in the order of time execution because it’s easier to see the logic of the expression. If you ever need to change the expression, you’ll be able to grasp the expression’s actions more quickly.
The flattened Balloon returns to its correct position at the origin.
Balloon inflates for two seconds, then rises. As it rises, it jumps slightly higher at approximately frame 48.