Control complex motion and forces
 
 
 

The following sections describe techniques for controlling complex motion and forces, including,

Keying impulses to rigid bodies

You can key an impulse on and off to instantaneously change a rigid body’s velocity, for instance, when a bat hits a baseball.

To key the impulse

  1. Select the rigid body.
  2. At the first frame of the animation, use the Attribute Editor to key the Impulse X, Y, Z and Spin Impulse X, Y, Z to 0, 0, 0.
  3. Go to the frame where you want the impulse.
  4. Key new values for the Impulse X, Y, Z and Spin Impulse X, Y, Z.
  5. Go to the frame after the one where you keyed the attributes.
  6. Key Impulse X, Y, Z and Spin Impulse X, Y, Z to 0, 0, 0.
  7. Set the tangents of all keys to stepped in the Graph Editor or Time Slider.

    For example, select a keyframe in the Time Slider, select the attributes in the Channel Box, then right-click the Time Slider and select Tangents > Stepped. Repeat this for each keyframe.

Combine rigid body dynamics and keys

When a rigid body is passive, you can animate it by keying its Translate and Rotate attributes. When the rigid body is active, you can animate it with dynamics, specifically fields and collisions. Sometimes you’ll want to use a combination of keys and dynamics. For instance, you can roll a ball off a table with keys then cause the ball to fall with gravity.

To use dynamics after keys

  1. Select the object.
  2. Key the object’s Translate and Rotate attributes to give the object motion.
  3. At the first frame of keyed motion, select Soft/Rigid Bodies > Set Passive Key.

    This keys the Active attribute to the off setting and keys the object’s current Translate and Rotate attribute values.

  4. At the first frame where you want the dynamics to have control, select Soft/Rigid Bodies > Set Active Key.

    This keys the Active attribute to the on setting and keys the object’s current Translate and Rotate attribute values.

  5. Apply the dynamics to the object.

    At a subsequent frame, you can switch control from dynamics to Translate and Rotate keys by selecting Soft/Rigid Bodies > Set Passive Key.

To use keys after dynamics

  1. Select the object.
  2. Make the object a rigid body and use dynamics to control its motion.
  3. At the first frame where dynamics control the motion, select Soft/Rigid Bodies > Set Active Key.

    This keys the Active attribute to the on setting and keys the object’s current Translate and Rotate attribute values.

  4. At the first frame where you want the Translate and Rotate keys to have control, select Soft/Rigid Bodies > Set Passive Key.

    This keys the Active attribute to the off setting and keys the object’s current Translate and Rotate attribute values.

  5. Set keys to control the motion.

    At a subsequent frame, you can switch control from Translate and Rotate keys to dynamics by selecting Soft/Rigid Bodies > Set Active Key.

    TipWhen you animate rigid body motion with dynamics after keys, the velocity that exists immediately before the switch to dynamics is added to the dynamic motion. When you animate rigid body motion with dynamics followed by keys, the rigid body adopts the keyed position immediately when you switch to keys. The prior dynamic velocity is not added to the keyed motion.

Get data on velocity, forces, and collisions

A rigid body has read-only attributes that contain its current velocity and any forces and collisions applied to it. This section describes these attributes.

Force, velocity, spin, and torque attributes

When you select a rigid body, the Attribute Editor shows the current X, Y, and Z component values for Velocity, Spin, Force, and Torque. You can also query these attributes in MEL commands or expressions by using the attribute names in the following table.

Example runtime expression

print (velocityX + "\n");

This displays the contents of velocityX in the Script Editor each frame.

Contact attributes

A rigid body has read-only attributes that contain data on the contact made with it during collisions. You can query the attributes in MEL commands or expressions by using the attribute names in the table that follows.

To accumulate data in these attributes, select the solver that controls the rigid body, display the Rigid Solver States section of the Attribute Editor, then turn on Contact Data attribute. The attribute values are zeroed out each time you turn on Contact Data. Turning on Contact Data slows playback.

Example runtime expression

print (rigidBody1.contactCount +"\n");

This displays the number of contacts each frame.