T u t o r i a l  -  Dynamic Parenting

 Skill Level: Intermediate 

What:
Using this method, you can blend from one parent to the other, whereas with a regular hierarchy something is either a parent or it's not -- there are no kinda sorta parents.  There's none of that child neglect with this method; all parents can love the child equally.

Why:
This is a tremendously useful tool.  Besides the obvious uses, like being able to have a character pick up a glass from a table, it can be used for things like having two goals for an IK chain and being able to choose--and animate-- between them.

More what:
The parenting reads the world coordinates of the parents and sets the child's values to that.  There's also an on/off variable slider, so the parenting can be turned on or off at any time.  It can even be partially on.

I'm going to use a slight variation here: I'm not going to use Dynamic Parenting on the real child object.  I'm going to dynamically parent a null object, then use normal parenting to parent my child object to that null.  The reason for this is that the Dynamic Parent function will override the child's motion and will not allow you to keyframe it (unless the On/Off slider is set to off).  With this method, the child object can be animated at any time.

And now, Ladies and Gentlemen... Dynamic Parenting!
1)
First let's create a slider and prepare it.  In Setup, go to the Add block on the Items sub-tab and create a slider and rename it to Dynamic_Parenting.  Then on the Values block which will appear below, rename xpos to ParentSelector and ypos to OnOff.  Lastly, turn off the channels you don't need by right-clicking on the Key Modifier buttons.

2) Load Box.lwo andSmallBall.lwo from the Objects\Tutorial_General\  folder, then clone the Box.  Rename them to Box_A and Box_B.

3) Add two null objects and name them Parent_A and Parent_B, then parent each to the box that matches the letter.  You'll see why we're using null objects a little bit later.  Basically, as you'll see, it gives us more freedom and control.  (Yes, I know that seems like a contradiction.)

4) Move the boxes away from each other so later you'll be able to see the parenting effect.

5) Add a Null called DP_Child_Null, then parent the SmallBall to it.

6) Go to the Command tab and create a New Variable on the Variables block.  Name it DynamicParenting on the Expression block.

7) On the Expression block, select  DynamicParent  from the functions pulldown list, then fill in the arguments:

  1. The first parent object.  Choose:  Parent_A

  2. The second parent object.  Choose:  Parent_B

  3. The child object.  Choose:  DP_Child_Null

  4. The position variable.  0 will parent it to Parent_A, and a 1 will parent it to Parent_B.  We want to be able to animate this so we'll use a slider.  Type (exactly):  [Dynamic_Parenting:chan[ParentSelector]]

  5. The degree of parenting.  0 is off, and 1 is on.  We want to be able to vary the degree, so we're going to put a slider as the variable.  Type (exactly):  [Dynamic_Parenting:chan[OnOff]]

After that's all filled out, apply the expression.

That's all there is to set up Dynamic Parenting.  However, you'll notice that the ball has disappeared.  It is inside one of the boxes.  The reason for this is that the parenting places the child at the pivot point of the parent, and the ball object is parented to DP_Child_Null, which is dynamically parented to Parent_A, which is now at the pivot point of Box_A.  To verify this, move the ParentSelector slider left and right.

8) Select Parent_A and move it up (Y axis) and you should see the ball come with it.  All you have to do is place it (Parent_A ) where you want on the box.  Whenever the ball is parented to it, it will go where the Parent_A  null is (even if the null's position is animated).  And the ball itself can be animated too.

9) Move the ParentSelector slider all the way to the right, then select Parent_B and position it (and therefore the ball) to where you want it.

Now, when you move the ParentSelector slider, you'll see the ball go to where you want it on each of the boxes. When you move the OnOff slider, you'll see the parenting itself turn on or off (or in between).  The DP_Child_Null'sposition can not be keyframed unless the OnOff slider is set to off, but the ball can always be keyframed, because it's just using regular parenting.

In the animation below (and in the finished scene file), the boxes and D_Child_Null are animated bouncing up and down, then the dynamic parenting is turned on and switched from one parent to the other, then turned off again.

So, the way you would use it is:  set up the Parent Nulls to where you want the child to go (like a table top and your character's hand), then dynamically parent a null object to go to those nulls.  Your real object will be parented to that Dynamic Parent null, so it can be animated on its own.  You could have the ball roll across the table and have the character pick it up, then move it around in his hand.

And that's the magic of Dynamic Parenting!

You can also add additional parents if necessary.  Just add a new null object for each additional parent, parent it, add the DynamicParent function, and you're all set.  (The next one may be one that chooses between Parent_A and Parent_C, for example.)

Then, of course,  you can go really crazy and put Dynamic Parenting on the parents!  That way you'll have an item that is dynamically parented to dynamically parented objects.  And so on, and so on.

A finished example of this tutorial is in the Scenes\Tutorials folder.  It is called Expressioins_DynamicParenting_01.fxs.  What you'll see in that scene are the parent boxes bouncing around, with the ball being parented back and forth, plus the ball doing its own animation, then the parenting being turned off.

Additional information:
General Info - Sliders
   General Info - Functions

Converted from CHM to HTML with chm2web Pro 2.82 (unicode)