Skip to main content
Atte J.
Inspiring
January 18, 2022
Question

Animated parenting...?

  • January 18, 2022
  • 2 replies
  • 222 views

How are you doing animations where an object (layer) "grabs" another layer, moves it around and then "releases" it leaving where it is and keeps moving itself?

 

Does that make sense?

 

So what I'm ideally looking for is an on/off-type animatable parenting. Is there an easy expression perhaps?

This topic has been closed for replies.

2 replies

Mylenium
Legend
January 18, 2022

Aside from Dan's code, there's any number of scripts on AEScripts.com that can do "dynamic parenting" and set it up for you, including DUIK, but also others.

 

Mylenium

Dan Ebberts
Community Expert
Community Expert
January 18, 2022

This is a position expression where you can use a checkbox to turn parenting on and off. When the checkbox is on, the layer will track the "Parent" layer's movement. You could modify the first line to use it with scale or rotation as well.

p = thisComp.layer ("Parent").position;
cb = effect("Checkbox Control")("Checkbox");
accum = value-value;
if (cb.numKeys > 0){
  n = 0;
  n = cb.nearestKey(time).index;
  if (cb.key(n).time > time) n--;
  if (n > 1){
    if (cb.key(n).value) accum += p - p.valueAtTime(cb.key(n).time);
    for (i = n-1; i > 0; i--){
      if (cb.key(i).value) accum += p.valueAtTime(cb.key(i+1).time) - p.valueAtTime(cb.key(i).time);
    }
    if (cb.key(1).value) accum += p.valueAtTime(cb.key(1).time) - p.valueAtTime(0);
  }
}else{
  if (cb.value) accum = p - p.valueAtTime(0);
}
value + accum