Advanced workflow: Use constraints and expressions with animation layers
 
 
 

You can use animation layers with constraints and expressions to drive objects in your scene. The simplest workflow is to first create a constraint to drive an object that has no animation, then create layered animation on top to offset the effect of the constraint.

You can also add constraints and expressions to animation layers, although this workflow is more complex and includes some known limitations. (See Known limitations for animation layers and constraints.)

To set up a constraint or expression to drive an object with layered animation, you must locate the layer’s blend node that corresponds to the attribute you want to be driven. You then set up the constraint or expression to drive the inputB attribute of that blend node.

The following examples describe how to create a constraint and an expression on an animation layer.

To create a constraint on an animation layer

  1. Create a new scene with two objects. This example describes a scene containing a cone and a sphere.
  2. Select the sphere and click to create a layer. (The new layer is named AnimLayer1 by default.)
  3. In order to better visualize the result of your constraint animation later, create some basic animation on the sphere and the cone as follows:
  4. Select the cone, select the sphere, then create a point constraint. (See Create point constraints.)

    This creates a pairBlend node in the Hypergraph.

    NoteIf an object already has animation when you create a constraint, Maya creates a pairBlend node. When you create animation layers, the layer nodes are created before the pairBlend node in the dependency graph.
  5. In the Animation Layer Editor, select Layers > Package Into Containers.
  6. Select the sphere and open the Hypergraph window ( Window > Hypergraph: Connections) to view its connections.

    The output of the point constraint (constraintTranslateX, constraintTranslateY, constraintTranslateZ) is connected to the pairBlend node, which in turn is connected to the sphere. For example, pairBlend1.outTranslateX is connected to pSphere1.translateX, and so on.)

  7. Click to create another layer for the selected sphere (AnimLayer2).
  8. Select Layer > Package Into Containers.
  9. In the Hypergraph window, double-click to expand the AnimLayer2 container, then the AnimLayer2_BlendNodes sub-container.

    The blend nodes for each of the sphere’s attributes display.

  10. Connect the output of the constraint to the input of the sphere’s blend nodes. For example, connect constraintTranslateX to pSphere1_translateX_AnimLayer2.inputB.
  11. Delete the pair blend node.
  12. Connect the output of the layer blend nodes to the sphere. For example connect the pSphere1_translateX_AnimLayer2.output to pSphere1.translateX.
  13. Play the result animation.

    The sphere now moves side-to-side (based on the original animation you created on its TranslateX value) as well as up-and-down (driven by its point constraint to the cone).

The following example describes how to add an expression to the translateY attribute of an object with layered animation.

To create an expression that drives layered animation

  1. Create a new scene and add any object you want to animate with an expression. This example describes animating a sphere.
  2. In the Animation Layer Editor, click to create an empty layer. The new layer is called AnimLayer1 by default.

    The next steps describe how to add an expression to AnimLayer1 in order to drive the sphere’s translateY attribute.

  3. Do the following to locate the blend node to which you will connect your expression:
  4. Open the Expression editor (Window > Animation Editors > Expression Editor), select inputB in the Attributes area.
  5. In the Expression Editor, write the expression that will drive the inputB of the blend node. (See Creating animation expressions.)

    The expression you write for the inputB attribute now drives the sphere’s translateY animation on AnimLayer1.

    For example, to add a sine function that drives the sphere’s translateY value, enter the following:

    pSphere1.translateY = sin(time);

    This expression makes the sphere move up and down following a sine wave that varies with time.

Related topics

Known limitations for animation layers and constraints

Note the following known limitations and workarounds when using animation layers with constraints.