Show in Contents
Add to Favorites
Home: Autodesk Maya Online Help
Keyframe two characters on separate animation layers
Example workflows with animation layers
Animation Menus
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
- Create
a new scene with two objects. This example describes a scene containing
a cone and a sphere.
- Select
the sphere and click to create
a layer. (The new layer is named AnimLayer1 by default.)
- In
order to better visualize the result of your constraint animation
later, create some basic animation on the sphere and the cone as
follows:
- Set
keys on the sphere’s translateX value to create a basic side-to-side
animation.
- Set
keys on the cone’s translateY value to create an up-and-down animation.
- 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.
- In
the Animation Layer Editor, select Layers
> Package Into Containers.
- 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.)
- Click to create
another layer for the selected sphere (AnimLayer2).
- Select Layer
> Package Into Containers.
- 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.
- Connect
the output of the constraint to the input of the sphere’s blend nodes.
For example, connect constraintTranslateX to pSphere1_translateX_AnimLayer2.inputB.
- Delete
the pair blend node.
- Connect
the output of the layer blend nodes to the sphere. For example connect
the pSphere1_translateX_AnimLayer2.output to pSphere1.translateX.
- 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
- Create
a new scene and add any object you want to animate with an expression.
This example describes animating a sphere.
- 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.
- Do
the following to locate the blend node to which you will connect
your expression:
- Open
the Expression editor (Window > Animation
Editors > Expression Editor), select inputB in
the Attributes area.
- 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.
Known limitations for animation layers and constraints
Note the following known limitations and workarounds
when using animation layers with constraints.
- Layers
containing constraints or expressions cannot be exported using the Animation
Layer Editor export tool. (See also
Import and export animation layers.)
- The Graph
Editor does not fully support animation layers with constraints.
Constraint attributes always display associated with the BaseAnimation,
even when they are added to a layer.
- If
you reconnect a constraint, the offsets are not adjusted and the
constrained objects will move. To manually adjust the offset, create
a new layer containing the attributes you want to adjust, place
the object where you want it in the scene, and set a keyframe on
the new layer.
- You
cannot edit a Set Driven Key curve with the Set
Driven Key window once the curve has been added to an
animation layer. You can still edit the curve using the Graph
Editor. (See also
Set a driven key relationship.)
- You
cannot add a new source to a multi-source constraint once it has
been moved to an animation layer. Instead, create multiple layers
with multiple instances of the constraint.