Passing Around an Object

Eventually in animation you will encounter this tricky but common scenario: An object will need to pass from one moving thing to another. For example, a character picks a ball off a table and throws it. The ball starts at the table, moves to the hand, then ends up in world space as it's animated flying through the air. So how do we deal with this transition?

There are a couple different methods that this tutorial will overview, but the primary focus will be on using constraints since they only require one object and are easily scalable.


Site Gags

An older, brute force way of solving this problem is using "site gags". In this method there needs to be a copy of the object in each different location needs to pass through. For example, in the scenario described above there would be three balls: one on top of the table, one in the character's hand, and one in world space. The trick here is that only one of these copies is visible at a time.

The ball on the table would be seen first. As the hand "picks" it up, that ball is hidden and the one in the hand is shown. Then when the character is just about to release the ball from the throw, the ball in the hand is hidden and the one in world space is shown.

Though this method is assured to work, it can sometimes be difficult to keep track of all the parented hidden objects. This also doesn't work very well with referencing.

 

Constraints

The preferred way of passing an object between surfaces and characters is using a setup involving constraints. The main two advantages of this method are that it only requires one object and that it is fairly scalable. You can have one object pass between many different target objects fairly easily.

To become familiar with this method you will be using the example file found on the network:

O:\unix\projects\instr\capstone4\cse459_au15_rigs\recruit_rig_constraint_exercise.ma

In this scene you will find the recruit rig animated picking up a ball, putting it from the left surface to the right surface, ending with the right surface lowering out of frame. The catch is that the ball hasn't been properly constrained yet. It is time to fix this!

  1. In setting up a system of constraints the first thing to consider is where the ball will need to be throughout the animation. For each separate location you'll need an "anchor", which is some sort of 3D transform the ball can eventually latch onto. In this scene there are three spots that need anchors: The left surface, right surface, and the recruit's hand.

    We'll be using locators for this purpose. For each location go to Create → Locator. Their default size is pretty small, so you may want to up the scale values to something like 10, 10, 10. Set the locators up like this:

    • Name the first locator "left_table_anchor". Position it above the left_table. It doesn't need to be exact though it probably wouldn't hurt. You can get an approximate placement by holding the 'v' key for vertex snapping and moving the locator to a corner of the table.

      After you've placed the anchor you will want to pin it to the table. Select the left_table, shift select left_table_anchor, then go to Constrain → Parent (options). Make sure Maintain offset is checked and click Add.

    • Name the second locator "right_table_anchor". Repeat the same process to pin it to the right_table.

    • Name the third locator "hand_anchor". This time just select the recruit's hand, shift select hand_anchor, then parent constrain with maintain offset unchecked. This is just so the anchor snaps to the middle of the hand.
  2. The anchors should now be ready to go!

  3. The next goal is to attach the ball to all three anchors such that it will be able to switch freely between them. However, you don't want to directly constrain the ball to the anchors because that would prevent you from adding any further keyframes to it.

    To circumvent this issue, select the ball's top con and hit Ctrl+g to make a group. This is what you will constrain instead. Name the group "anchor_attachment" then go to Modify → Center Pivot.
  4. Attach the ball to the anchors. Select the anchors first then finally anchor_attachment. Order is important! Now make a parent constraint with maintain offset checked. The ball, via its parent group, is now attached to all three anchors simulataneously.

    You may notice the ball hasn't moved. That's because maintain offset has properly set the offsets relative to all the other anchors. This is fine for the left_table_anchor but not so for the other ones. We'll fix this as we go, though.

    If you go under anchor_attachment in the Outliner you'll notice the parent constraint will be represented by the node "anchor_attachment_parentConstraint1". First, rename it to "switcher" since this is what you will be keying to switch the ball from one anchor to another. Second, in the Channel Box you'll see a list of target weights. Go ahead and set the Left Table Anchor weight to 1 and the other weights to 0. Think of this as a switch. You only want one of these values to be 1 at any given time.

    Everything is all set up now! Now to move along the animation and switch the ball between the various anchors.
  5. The first switch point is going to be at about frame 14. Select the switcher and set a keyframe on that frame. Now go to frame 15. Set the Hand Anchor weight to 1, the other weights to 0, and set a keyframe. The ball now goes from being attached to the left_table_anchor to being attached to the hand_anchor.

    Despite this, you'll notice that on frame 15 the ball has flown off into space. That's because it's still using the old constraint offset values but relative to a new 3D point of reference. Luckily there's a fairly easy way to update those offset values. Open up the Attribute Editor for switcher and you'll notice that all these offsets are listed under Parent Constraint Target Offsets.

    Middle-click the timeline from frame 14 to frame 15. The animation shouldn't have updated. Next, under Parent Constraint Target Offsets click Update then click Key. The offsets should now be updated.

  6. Go ahead and repeat the previous step to switch when the recruit lets go of the ball onto the right table. This will be at about frame 35 and 36.