Advanced workflow: Use constraints and expressions with animation layers

 
 
 

You can use animation layers with constraints and expressions to drive objects in your scene. For information on adding constraints to animation layers, see Add constraints to animation layers.

Note that the workflow for adding expressions to animation layers is more complex and includes some known limitations. (See Known limitations for animation layers and constraints.)

To set up an 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 expression to drive the inputB attribute of that blend node.

This 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. With the sphere selected, click in the Animation Layer Editor to create a layer containing the sphere attributes. 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:
    • In the Animation Layer Editor, select Layers > Package Into Assets. (See also Package animation layers into assets.)
    • Open the Hypergraph window (Window > Hypergraph: Connections), double-click to expand the AnimLayer1_Asset, then double-click to expand the nested AnimLayer1_BlendNodes asset.
    • Select the pSphere1_translateY_AnimLayer1 blend node.

      This is the blend node that corresponds to the sphere’s translateY attribute.

  4. Open the Expression Editor (Window > Animation Editors > Expression Editor).
  5. Select inputB in the Attributes area, then type an expression to drive the inputB of the blend node in the Expression area.

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

    pSphere1_translateY_AnimLayer1.inputB = sin(time);
    

    (See also Creating animation expressions.)

  6. Click Create.

    The expression you write for the inputB attribute now drives the sphere’s translateY animation on AnimLayer1. The example expression makes the sphere move up and down following a sine wave that varies with time.

Known limitations for animation layers with constraints and expressions

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

Related topics