Activity › Forums › Adobe After Effects Expressions › Inherit only position property from parent
-
Inherit only position property from parent
Posted by Obed Ampong on May 30, 2019 at 2:51 pmHello,
Is it possible to make a child inherit only position properties from the parent without the scale properties? I need to move the position of the child with the parent however want to maintain the scale of the child even if the parent scale properties change.
Thank you.
ObedObed Ampong replied 6 years, 11 months ago 2 Members · 6 Replies -
6 Replies
-
Miguel De mendoza
May 30, 2019 at 3:37 pmTry this on child position:
parentPosition = thisComp.layer("Parent Layer Name").transform.position;
value + parentPosition // Remove this line if you need locked child
-
Obed Ampong
May 30, 2019 at 4:33 pmPlease, what if I want the child position[0] to be affected by the scale.
For example, the parent is a bar graph and the child is the label( %). I would like to keep the distance between the graph and the label (%) so that if I increase the scale of the bar the label will move a little further away from its position, however, I would like to keep the position[1]of the label(%) freely so that it can inherit the position[1] of the bar graph.
Thank you -
Miguel De mendoza
May 30, 2019 at 5:19 pmFor plain relatinships, just change position by the property you want to parent:
parentPosition = thisComp.layer("Parent Layer Name").transform.position;
parentScale = thisComp.layer("Parent Layer Name").transform.scale;
parentOpacity = thisComp.layer("Parent Layer Name").transform.opacity;
parentScaleX =parentScale[0];
////and so on ....
For what you are looking for explicitly:
thisParent = thisComp.layer(""Parent Layer Name"");
parentPos = thisParent.transform.position;
parentScaleWidth = thisParent.transform.scale[0];
toRight = thisParent.width/2 * parentScaleWidth/100 + parentPos[0];
[toRight + value[0], value[1]] -
Obed Ampong
May 31, 2019 at 3:48 amHi Miguel,
Thanks for the reply, it worked but is it possible to factor in the anchor point? I have my anchor point set to the extreme left of the parent while the child is at the extreme right end.
regards,
Obed -
Obed Ampong
May 31, 2019 at 9:43 amPlease, is it also possible to keep equidistance between them all the time?
Reply to this Discussion! Login or Sign Up