Sign up to our twice-monthly newsletter today for the latest tutorials, interviews and product information.

Setting up animation controls in Maya

By Martin Andersson

Web: Open Site

Date Added: 9th December 2009

f(x) = sin(x). Sounds familiar? Good. If not, let's take a minute to explain the sine function. Sine, Cosine and

T angent are used much in trigonometry. The unitcircle is a very good tool when it comes to angles and these

mathematical functions. Let's take a look at the unitcircle.

Looks confusing? Well, let's strip it down. Notice the triangle at 30 degrees.We use sine to determine the value of the opposite line. (.sA) and cosine to determine the nearby line.

(.cA) sin30 = 0.5, cos30 = 0.866.

Look at the two axis in the circle. You have X from "-1" to "1" and Y from "-1" to "1". The sine value is read from the Y-axis (see dotted line) I'm going to take a trip all the way around the circle and list the values I get:

The values in paranthesis are the distance traveled on the circle. You don't have to understand this to get the point at the end.

If we take a look at this graph we see that the sinecurve is a neverending curve with the same pattern all over. If we go two rounds around the unitcircle (720 degrees) we would end up at the y-value 0 and 4 pi.

How is this usefull for us? If you are an animator you have already told yourself that this graph represents a repeating wobbleanimation or it could be an elevator with smooth translateY etc. etc.

We want the curvature on the plankBendDeformer to go from "-1" to "1". The sinecurve is perfect for this so therefore we write an expression where the value of the attribute "curvature" is controlled by a sinecurve

Call our new expression "stoneTranslateYSine" and press enter. Now write this into the expression - textfield.

pStone.translateY = sin(90); and click Create.

Maya returns the rather odd result 0.894 (read the translateY attribute, now marked purple/lilac because an expression is linked to it ) I'm not quite sure why this is, but I recon maya reads radians since sin(deg_to_rad(90)); returns 1

Fear not, we can use sind (sinusdegrees). sind(90) will return "1".

If we use sind(frame) instead of a set value maya will fill the current frame in. e.g. at frame 10; sin(10), at frame 90; sin(90) Try this one out and hit play.

pStone.translateY = sin(frame);

If you have the timerange set from 0 to 90 you can see that it takes 90 frames to get the translateY to "1" If you've been paying attention you should be able to guess this result before you saw it in Maya. We are getting somewhere now.

We want a higher frequence. Taking 90 frames to get half a sinecurve isn't quite usable. I tried a couple of values and this is what I am looking for:

pStone.translateY = sin(frame*56):

It's rather quick, but I'll use the vibrateValue to ease it in and out later. Now I want you do one last thing with the stone before we go to the plankBendDeformer.Go to "Edit - Keys - Bake Simulation/optionBox".

Reset the settings (Edit - Reset Settings) and change Channels to "From Channel Box". Set Time Range to "Start/End" and set Start Time to 0 and End Time to 90. Select pStone.translateY in the channelBox and hit Bake.

Maya will now bake the animation by reading the value at each frame and set a key. Let her finish and open

the graphEditor (Window - Animation Editors - Graph Editor...) And... We're in sine-land:

Now we're going to do what we intended to do in the first place. I just wanted you to fully understand the "sind- command". Rightclick-hold pStone.translateY and choose "Break Connections" . Now we deleted the keys. If we hadn't baked it we would have broken the expression by doing this. Set translateY to "0" and leave the stone alone.

We're going to use what we have just learned to create the wobbleEffect for our plank. Let's directly trasfer the lines of code we found usefull earlier. Select plankBend and click plankBendDeformer under INPUTS. Rightclick-hold Curvature and release over Expressions. Now write this into the expression-textField:

plankBendDeformer.curvature = sind(frame*58);

By looking at the line above you should be able to imagine the plank go crazy. Click create to find out that you're absolutely right :) "Ahrg, it's crazy, we have to stop it!!". No problem.

plankBendDeformer.curvature = (sind(frame*58))*(plankControl.vibrateValue);

Let's try to animate it then. Grab plankControl and set a key at frame 0, vibrateValue "0", a key at frame 10, vibrateValue "1" and at frame 57 set vibrateValue back to "0".

Now it starts at impact and eases out over about 40 frames... I had to tweek my expression to get it to look better. Remember that you can edit expressions to fit your need. Here's what I got:

plankBendDeformer.curvature = (sind(frame*78))*(plankControl.vibrateValue/3);

Now, all you have to do is animate the stone and tweek the vibrateValue to match the animation.

Here's the relationship between the vibrateValue and the curvature after modification of the expression:

Feel free to download the file here and play around with it (Maya 7.0):

I did not write this tutorial because I mean this is the best way to do this task. I wrote it to show you that possibilities with expressions are endless. Good luck creating nifty expressions

< previous page

1 | 2

Related Tutorials

Readers Comments (Newest on Top)

No comments yet. Be the first to comment!