Switch Parenting Between Two Layers in After Effects

In Adobe After Effects, you can use expressions to have one child layer follow two parent layers and control when it follows each parent. Here’s how you can do it:

  1. Create Your Parent and Child Layers:
    • Import your assets and create three layers: two-parent layers and one child layer.
  2. Position the Parent Layers:
    • Position the two parent layers where you want them to be.
  3. Parent the Child Layer:
    • Parent the child layer to one of the parent layers first. You can do this by selecting the child layer and then using the pick whip (the spiral icon) to link it to the desired parent layer. This means that initially, the child layer will follow this parent.
  4. Create Expressions:
    • Alt-click (Option-click on Mac) on the stopwatch icon next to the child layer’s Position property. This opens the expressions editor.
  5. Write an Expression:
    • You’ll write an expression that uses a conditional statement to determine which parent layer the child layer should follow at any given time. Here’s a basic example:
  • In this example, “Parent Layer 1” and “Parent Layer 2” are the names of your two parent layers. You can change the followParent1 variable to true or false to switch between following the two parents.
JavaScript
var parent1 = thisComp.layer("Parent Layer 1");
var parent2 = thisComp.layer("Parent Layer 2");
var followParent1 = true; // Change to false to follow parent2

if (followParent1) {
    parent1.toWorld(parent1.anchorPoint);
} else {
    parent2.toWorld(parent2.anchorPoint);
}

By using this expression, you can make the child layer follow either of the two parent layers based on the conditions you set using keyframes or other control methods.

Here is an old technique variant of switching between 2 parent layers:

\\Create Slider on Layernlayer1 = XXXXX.position; // Replace XXXXX with a pickwhip from first parent layernlayer2 = XXXXX.position; // Replace XXXXX with a pickwhip from second parent layernslider = effect("Slider Control")("Slider")/100; //Slider will move between 0 to 100n(layer1*slider)+(layer2*(1-slider));

Leave a Reply

Your email address will not be published. Required fields are marked *