Zen and the Art of Dynamics

Maya has built in dynamics which allow you to apply the laws of physics in order to create *real* (read: simulated) dynamic motion.  After you create the simulation it is possible to bake it.  Baking a simulation will give you keyframes.  Once your simulation is baked you can remove the dynamics and make use of the less processor intensive keyframe animation.  This process will give amazingly real animation.

It is possible to do some pretty crazy things using maya's dynamics.  Like everything else in maya you can make things as complicated as you like.  But for the sake of your sanity I'll keep this one as simple as possible.

In this tutorial we will use gravity and rigid bodies to make a cube (or sphere, cylinder, or whatever you want) fall from the sky and bounce around on the ground.

So first we need to create a normal polygonal cube and plane.  I have rotated my cube a bit just so I get a more interesting bounce:

cubePlane

Now, in order to use these two objects in a dynamic simulation we have to turn them into what maya calls "rigid bodies."  There are two types of rigid bodies:

Active rigid bodies-  These are affected by other rigid bodies as well as forces such as gravity.
Passive rigid bodies-  This type of rigid body is not affected by gravity or other forces.
                                  However they will have an affect on active rigid bodies.

In this demo the cube will be an active rigid body and the floor will be a passive rigid body.  This means that gravity will push down on the cube, but not on the floor.  And when the floor and cube hit each other the cube will move but the floor will not.

Be sure that you are using the Dynamics menu set:

dynamicsMenuSet

Then with the cube selected go to:  Bodies>Create Active Rigid Body
Then select the plane and go to: Bodies>Create Passive Rigid Body

Both options can be found here:

createActive

If you were to play back the simulation right now you would see that nothing at all happens.  Before the cube will fall we have to add gravity.

Select the cube, then go to: Fields>Create Gravity
 
 

createGravity

Now go to: Window>Relationship Editors>Dynamic Relationships...
The Dynamic Relationship editor will pop-up.
Select your cube and make sure that the gravityField on the right is highlighted.
Whichever object(s) you have selected when you create gravity will be affected by the gravity.

relatEditor

If gravityField is not highlighted as it is above then click on it so that it is highlighted.  Then just to make sure, I would click on your plane and make sure that it does NOT have the gravityField highlighted.  If you choose the plane from the left side it should look like this:

noGravity

We are now finished setting up the dynamics.  Before you can play the simulation you need to make sure that your playback speed is set to "Free."  Setting the playback speed to free allows maya to calculate each frame before continuing on.  If you were to set it to "Normal [30fps]" then maya would be forced to move on to the next frame before it is ready.

Bring up the animation preferences by clicking on the icon on the bottom right corner of your screen:

animPrefs

Then change playback speed to free:

free

Now play the simulation and watch your cube bounce.  Remember to rewind to the begining of the animation before playing otherwise the dynamics will be 'confused' and random things will happen.

From here it is possible to "bake" the simulation.  Basically what that does is maya runs the simulation, calculating the changes in each object, and sets a keyframe.  Then you can use the keyframed animation instead of the simulated animation.  This gives much faster playback and a faster render.  For now I recommend rendering the animation with the simulation instead of with the baked keyframes.

more Maya tutorials
comments..suggestions..questions:  josh@occipital.net

the rest of my site is here: http://www.occipital.net