Animated parenting...?

Community Beginner ,
Jan 18, 2022 Jan 18, 2022

Copy link to clipboard

Copied

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

Views

24

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jan 18, 2022 Jan 18, 2022

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jan 18, 2022 Jan 18, 2022

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

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