Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Animated parenting...?

Explorer ,
Jan 18, 2022 Jan 18, 2022

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?

TOPICS
Expressions , How to
151
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2022 Jan 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 18, 2022 Jan 18, 2022
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines