You are on page 1of 1

Starting in with animation: Setting keyframes and the graph editor

Maya 1 Online - Additional Resources


Instructor: Adrian Herbez

Module 7 - Starting in with animation: Setting keyframes and the graph editor
Okay, so you've made a bunch of beautifully sculpted and textured models, and now it's time to start getting them moving! In this week's module, we'll be looking at
basic animation in Maya- setting keyframes, the graph editor, and using motion paths.

But before we get too into the nitty-gritty details, let's talk about the larger picture. Animation in Maya, and 3d applications in general shares more with stop-motion
animation than it does with hand-drawn, or "cell" animation. Interestingly enough, stop-motion animation predates cell animation- some of the earliest animations
were done by Thomas Edison utilizing more of a stop-motion like approach to combine live people with animated drawings ("The Enchanted Drawing", 1900), and
clay ("Fun in a Bakery Shop", 1902).

In the traditional approach to stop-motion animation, one starts by carefully crafting the characters and props for the animation, taking special care to build characters
that are capable of moving in the manner they'll need to to produce the animation. The process isn't that far removed from the kinds of considerations facing digital
animators as we model, texture, and rig models in preparation for animation. The models are then painstakingly positioned and posed, and a photograph is taken.
The model's pose is then changed slightly and another photograph is taken. The process continues until the animation is complete. It is incredibly time-consuming,
and very hard to achieve consistency. Most stop-motion animation, even when its really well done (Ray Harryhausen's work on films like "King Kong" for example)
looks a bit jerky, due both to low framerates and the slight jitter introduced by the chaos of the real world.

The wonderful thing about producing animation on the computer is that we can bypass many of the most frustrating aspects of animation and focus our attention on
making the actual motion more expressive and interesting. The term "keyframe" originated with the practice of establishing a hierarchy of animators in order to speed
the production of large projects. The lead animator would draw a few "key" poses- just enough to rough out the motion. For a character throwing a ball, that might
mean a default pose, a pose at the extremity of the wind-up, and one or two as the character throws the ball and follows through. The task of extrapolating from the
handful of frames produced by the lead animator to the hundreds or thousands of frames needed to produce quality animation fell to large numbers of animators that
had little to no creative input of their own and created frame after frame of in-between states. With the advent of digital approaches, each of us gets to be the head
animator on our projects, and the computer can easily churn out as many frames as we need it to in between each of our key frames.

The Nature of Digital Animation


The first thing to understand about animation using Maya or any other computer tool is that digital animation, like everything else that exists on computers, is on some
level a string of numbers. One of the great things about Maya is that it takes great pains to avoid hiding this from the user. Animation in Maya is simply values
changing over time. While the bulk of your animation will likely consist of keyframing the position and rotation of objects, almost every number in Maya (and
everything in Maya is numbers) can be keyframed. Always keep this in the back of your mind as you approach animation, as oftentimes the answer to "How do I..."
lies in merely finding the right attribute of the right object and setting a keyframe.

So without further ado, let's start looking at how basic animation works in Maya.

Types of animation in Maya


With as diverse a toolset as Maya, it makes sense to break down animation into a couple of different categories, each with its own approach/workflow.

• Transform Animation Keyframing the transform (position, rotation, and scale) of objects to make them move through space
• Deformer Animation Keyframing the shape of an object to make it morph or distort
• Skeletal Animation Actually a kind of deformer animation, but sufficiently important and common to merit a category of its own- the practice of using stand-in
objects called bones to cause a model to bend and change shape
• Driven Animation Animation brought about by one attribute "driving" another, via methods like Set Driven Key and the connection editor
• Dynamics Animation Animation that is created by simulating real-world physics and having objects respond to each other and forces in the environment
• Algorithmic Animation Animation defined by mathematical equations- in Maya this generally means creating expressions

The above are broad categories and there's a lot of overlap. If the diversity seems overwhelming, try to see it as just giving you more options as to how you approach
producing animation. The simplest of the above as well as the most fundamental is simple transformation animation, so let's take a look at how that works.

Objects in Maya consist of nodes linked together. Even simple objects, such as primitive shapes are two nodes- a shape node that holds the information that defines
the actual shape of the object, and a transform node that positions the object in the scene. An object's transform node holds position, rotation, and scale (size)
information for that object. Let's look at we can use those attributes to make a ball bounce.

Freezing Transformations
I'll create a NURBS sphere and move it off to one side, yielding the following result:

In the channel box, notice that we see the current values for the translation, rotation, and scale of the sphere. Since I moved the ball up to make it sit on the grid, and
moved it back from the origin a bit, the values for both Y and Z are non-zero. Each of those values is a relative one, rather than an absolute- in other words, 1.032 for
translate Y means that the sphere is 1.032 units above (since it's a positive number) its original reference point. Rotation works in the same way and indicates the
number of degrees from the original rotation. Scaling is similar, but notice that it starts at 1, rather than 0. Scaling is also relative, but more of a percentage than
anything else. Therefore, 1 means 100% of the original size, and .5 would mean 50%.

While it doesn't matter too much in this case, you will occasionally want to tell an object that it's current position, rotation, or scale should be the reference point from
which its position, rotation, and scale are determined. This can be really important, as much of the animation you'll create will work by Maya telling an object to move
or rotate, and the way in which it does that is determined by what it thinks it means to move along each axis.

For example, if I was to scale and rotate a sphere, I might end up with something like this:

Notice that with the rotate manipulator selected, the X axis is pointed off at an angle. This could create problems if I wanted it to rotate around a perfectly horizontal or
vertical axis, as neither the object's X or Z is perfectly aligned anymore. Luckily, Maya provides a very straightforward way of fixing such issues via the "Freeze
Transformation" command. Selecting an object and going to Modify->Freeze Transformations will reset all of the translation and rotation values to 0, and the scale
values to 1 without changing anything about where the object is, how it's rotated, or its size. It effectively just sets a new reference point for the transform values to be
based on. Additionally, by going to the option box, you an specify which transform attributes to freeze. You'll usually want to do it to all of them, but there may be
situations in which you'll want to apply it selectively.

Note that there is also a "Reset Transform" command in the modify menu. This will also set the values for translation, and rotation to zeros and the values for scale to
ones, but it will cause the object to snap back to its original position. The difference between reseting and freezing is easy to see by comparing their results:

Notice that in both cases, the values for position and rotation are all zeros, and the values for scale are all ones, and the rotation widget is aligned with world
coordinates (straight horizontal/ vertical), but freezing maintained the rotation and stretching, while resetting undid them. It's common to end up with slightly
misaligned local coordinates as a result of the modeling process, so it's often a good idea to freeze transformations in preparation for animation.

Setting Keyframes
So now after freezing the sphere's transformations, I'm ready to start animating it. You may know that hitting the "S" key will set a keyframe on selected objects, but
you won't usually want to animate that way. The reason for that is that there are a number of different ways of controlling/creating animation in Maya, and keyframes
are only one of the options. In addition to directly keyframing values for attributes, you might instead want to:

• Use the connection editor to link the attribute to another attribute


• Use Set Driven Key to tie the minimum and maximum of the attribute to another attribute
• Use constraints to control the attribute
• Write an expression to control the attribute

Each of the above methods has its uses, and you'll often want to combine several approaches to animate various attributes of the same model. However, while a
model can employ several different approaches, each attribute of the model can only be controlled via a single method. Therefore, if you set keyframes on an
attribute, you can't use an expression. If you use an expression, you can't use a constraint. If you're using set driven key, you can't use the connection editor.

So if you make it a habit to keyframe everything, you prevent yourself from being able to later use one of the alternative methods to drive that aspect of your
animation. Even if you do want to use keyframing exclusively to control the animation of your objects, you'll still only want to set keyframes for the attributes you're
animating at the moment. Often, it's a good idea to take a layered approach to animation, laying down the basic motion (say by keyframing the position of the key
objects) and then steadily refine the animation by adding more keyframes in between the main ones, either on additional objects (like making props a character is
wearing or carrying respond to the walking motion of the character) or on additional attributes (adding rotational animation on top of positional).

So given that hitting S isn't the best way to go, how do you set keyframes? One way of doing it is to select the relevant attributes in the channel box by clicking on
their names (Control-click to select multiple attributes). Right-clicking will bring up a menu from which you can select "Key Selected" to set keyframes on the selected
attributes:

That's a great way to go about setting keyframes on arbitrary attributes, but for the big three of translation, rotation, and scale, there's a set of keyboard shortcuts that
are every bit as quick as hitting S, but more specific, all involving the Shift key:

• Shift-W Sets a keyframe on the position (and only the position) of the selected object/ objects
• Shift-E Sets a keyframe on the rotation (and only the rotation) of the selected objects
• Shift-R Sets a keyframe on the scale (and only the scale) of the selected objects

The above keyboard shortcuts are great for setting keys on position, rotation, and scale, but always be aware that you can set keys on almost any number appearing
in Maya. The way to be sure is to open up the attribute editor and hold your mouse over the name of the attribute. You'll most likely see a small box appear directly to
the lower-right of the mouse pointer. That icon indicates that the attribute can be keyframed:

Right-clicking on any attribute that causes that box to be displayed on the mouse pointer will give you the following menu, allowing you to set a keyframe, set driven
key, or create an expression:

You can use the above approach to keyframe almost any number in Maya, allowing any number of things to happen.

So having talked about how to set keyframes, lets start doing it. So far I have one keyframe at frame 1 storing the positional information of the sphere. I'll move the
playback head forward a bit in preparation for setting the next keyframe.

Notice the thin red line at frame one, indicating that a keyframe has been set. Now I'll set a second keyframe, with the ball moved forward a bit. As you create
keyframes, you associate a given value for an attribute (in this case, the Z-position of the ball) with a given time (frame 1, for example). A single keyframe doesn't do
you any good, but once you have at least two, animation can happen. If Maya knows that the ball should be at position A at frame 1, and position B at frame 30, it's
smart enough to figure out where it should be at frames 2-29 via interpolation. Interpolation is the process by which Maya gets values to change smoothly over time-
in this case, given some difference in positions for the keyframes and 30 frames, Maya will move the ball 1/30th of the distance between the start and the end
position each frame, causing the ball to animate:

Now that I have the ball moving forward, I'll want to add more keyframes to layer vertical motion on top of the horizontal. Let's say I want the ball to bounce twice. I'll
start by moving the playback head midway between the first and last keyframes (frame 15 in this case), and setting a keyframe. This isn't so much to cause motion,
but rather to prevent it. When I add keyframes for each peak of the bounces, this middle keyframe will make it come back down in between.

Now I'll go to about frame 7 (roughly midway between 1 and 15), and frame 22 (between 16 and 30), and add keyframes that make the ball rise vertically, with it rising
a bit less on the second one.

Now that we have some animation, let's take a moment to talk about controlling the playback of animation in Maya.

Playback tools
Take a look at the bottom of Maya's interface- you'll see not only the timeline, but a few other options and setting that are good to know about:

Directly to the right of the timeline is a field that displays the frame number that the playback head is currently on. You can type numbers into that box to jump to a
specific frame, or just use it as a source of information as to exactly where you are. Just underneath the timeline are a number of items- four number fields and a
slider.

The two outer number fields are the starting and ending frames of the animation as it stands. In the above image, there are 600 frames of animation (the difference
between the 1 displayed in the far left box and the 600 displayed in the far right box). You'll often end up with quite a large number of frames (600 frames is only 20
seconds or so of animation), but only you'll generally only want to work on a subset of the overall animation at any one time. That's where the inner number fields
come in- they represent the current work range. In the above example, I'm currently looking at 90 frames of animation - from frame 1 (in the left inner box) to frame 90
(in the right inner box). It's these numbers that determine what frames are dis played in the timeline. What if I wanted to only look at 90 frames at a time, but I wanted
to work on the interval between frames 90 and 180 rather than 1 to 90? Thats where the slider in between the number boxed comes in- it allows you to drag it left and
right to change the specific set of frames you're working with.

To actually play the animation, you'll need to use the playback controls, displayed in the lower right corner of the screen:

There are two versions of each control- one that goes forward, and one that goes backward. They're fairly straightforward, offering buttons that play (in forward and in
reverse), step forward/back frame by frame, and go to the start or the end of the current range. The keyframe buttons are especially useful for editing animation, as
they will take you to the next (or most recent) keyframe. This is important, as if you want to alter existing animation, it's easy to accidentally add keyframes when you
mean to change the values for existing keyframes. If you always use the "next keyframe" and "last keyframe" buttons to alter keyframes, you'll avoid such issues.

Now that we have some animation, and we've talked about playback, let's look at how we can alter it in Maya.

Altering Keyframes
Once you've got some keyframes in your timeline, Maya lets you tweak them in a number of different ways. The simplest way is to move them around within the
timeline. To do that, shift-click and drag in the timeline. You'll notice that as you do that, keyframes will become highlighted in red.

Notice that there are two sets of triangles here- one at each end of the highlighted region, and two right next to each other in the center. Clicking and dragging on the
central triangles will let you move the selected keyframes forward and backward in the timeline, changing when things happen, but not their relative timing. Clicking on
the outer triangles, on the other hand, will let you stretch and compress the keyframes to speed up the animation or slow it down. You can also right-click on the
highlighted area to get a menu that will let you copy keyframes.

Once you've copied some keyframes, you can move to a different place in the timeline and paste the frames to re-use the animation. To do that, right-click on the
timeline at the place where you want the copied frames to start. From the ensuing menu, choose Paste->Paste to copy the keyframes into the timeline and cause the
motion to repeat. There are other, more in-depth and flexible ways of repeating animation in Maya, but that can be a simple and straightforward way of going about it.

If you really want to change existing animation in powerful, flexible, and subtle ways, you'll want to use Maya's Graph Editor. The Graph Editor displays animation as
a graph of values over time. It can be a strange way of thinking about animation at first, but once you get used to it, it's a very powerful tool for getting quality
animation out of Maya

Using the Graph Editor


To use the graph editor, we have to first open it up. To do that, go to Window->Animation Editors->Graph Editor. In the above example of the bouncing ball, I would
see something like this:

What we're looking at is a list of all the attributes of the selected object that have been keyframed. In this case, that means the translation along each of the X, Y, and
Z axises. Objects are displayed in the left-hand side of the window, with all their animated attributes being listed below. Notice that Maya color-codes the attribute
names with Translate X being red, Translate Y green, and Translate Z blue. This is a common rule in Maya - RGB = XYZ.

The color-coding extends to the graph as well, in that the red line is the graph of X position over time, the green line Y position, and the blue Z. Notice that the red line
is completely flat and straight, due to the fact that the ball is only moving in Z and Y. Selecting a specific attribute from the left-hand list will cause only the graph for
that attribute to be displayed. If I click on "Translate Z", I'll see the following:

The line winds downward, with a small black square indicating each keyframe. The first thing to remember about the graph editor is that you're not looking at a literal
path through space, but rather just a graph of some value over time. So the fact that the line is moving down doesn't have anything to do with the direction that the
ball actually moves. Down, in this context, just means that the value (in this case position in Z) is decreasing over time. Movement along Z isn't likely to ever look like
downward motion and, depending on the camera angle, might look like motion to the front, back, left, or right of the object.

Notice that the graph of the motion varies slightly- instead of moving in a straight line, it meanders a bit. Note that the meandering in the graph editor won't actually
result in the ball moving around in space- since the graph of the Z motion consistently moves downward, I'll have the ball moving in the same direction, but it will
seem to speed up and slow down a bit as the rate of change in the graph editor changes. Maybe I want that to be the case, but lets for the moment suppose that I
don't. To make the ball move straight forward along the Z axis, I might want to delete the extra keyframes in the graph editor. I can do that by clicking and dragging a
selection box over the middle three keyframes (being careful not to select either the first or the last keyframe), and go to Edit->Delete from within the Graph Editor.
That will delete the selected keyframes and result in the graph for translate Z being much cleaner- a single straight line from the start to the end:

Since there's no animation to the X translation, I might want to consider deleting all the keyframes to free up the X translation attribute. If I did delete all of the
keyframes, the translate X graph would be taken out of the graph editor altogether, as only attributes with keyframes are displayed:

Where the graph editor really gets useful, though, is in using it to tweak animation. By selecting keyframes, you can change both the specific value (by moving it up or
down) and the timing (by moving it left or right). Select the keyframe, make sure you have the "Move Keys" option selected (in the top left of the graph editor window),
and you can middle-mouse drag to change values:

You can also type in values for either value or frame directly. So if I wanted to make the ball move exactly, instead of approximately 15 units along Z as it bounces, I
could select the last keyframe for Translate Z, and type -15 into the field at the top of the window:

If we look at the animation we have so far closely, we'll see that it doesn't look very good or believable at the point where the ball hits the ground, as the ball changes
its direction and velocity in much too gentle a way, instead changing quickly in reaction to the impact. This too can be solved in the graph editor.

If you select a keyframe, you'll see two lines extending from it, one in each direction. Selecting either of the lines and middle-mouse dragging will change how the
curve changes as it passes through the point defined by the keyframe. In order to get sharper changes, you'll want to convert the tangents to "linear", meaning that
the graph of the curve will change direction suddenly at the keyframe. To do that, select the keyframe and hit the "Linear Tangents" button in the top of the window:

You'll likely also want to break the tangents, which will make the left-hand tangent (how the curve enters the keyframe) and the right-hand tangent (how the curve
leaves the keyframe) independent of each other and will allow for even sharper variation.

So if I wanted to correct the problem of the ball gliding as it bottoms out with the bounce, I would likely use the following process:

1. Original curve - unrealistic motion at the hit of the bounce


2. The curve after converting the keyframe to linear tangents
3. After moving the tangents a bit
4. After breaking the tangents and increasing the sharpness
5. Final animation curve after having been tweaked

Resulting in animation something like the following:

In general, when creating animation via setting keyframes:

• Be sure to only keyframe what you're animating at the moment (use "key selected" or the Shift+QWERTY shortcuts, rather than S)
• Layer your animation- lay down the big motions and then iterate to add more complexity and interest
• Use the graph editor to fine-tune your animations

In next weeks module we'll start looking at how you set up more complex models in preparation for keyframing via skeletons and skinning.

You might also like