Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Unparent layer at certain frame???

  • Unparent layer at certain frame???

    Posted by Juan Francisco on January 3, 2014 at 1:46 pm

    Hi there, I’m working with an animation and I need to unparent a layer at certain frame. Is there any way to do this via expressions? I’m setting one layer to follow another one via parent. Is there any way to do this via expressions?? And then I need to break the parenting at a certain frame, so both layers can be animated separately withouth the layer one following the other. Hope u can help me! THANKS!

    Jordan Santiago replied 9 years, 7 months ago 4 Members · 3 Replies
  • 3 Replies
  • George Goodman

    January 3, 2014 at 4:16 pm

    Easiest thing to do would probably be to just split the layer (cmd-shft-d or ctrl-shft-d on pc) and unparent the second half. If you really wanted to do it via expression this might work:

    Rather than parent the entire layer, just parent the position property and add an if/else parameter

    On the position property of the child layer add this expression:

    if (time<1) (thisComp.layer(“Purple Solid 1”).transform.position – [100,100]) else transform.position

    Change the value of time to the time you want it to stop following the the parent layer. Change the part in quotations to the appropriate name of the parent layer. Change the [100,50] to the difference in value.

    You’ll want to place the child layer where it should be at the time you want it to stop following. This expression is saying “be the same as the parent layer position minus 100px on the x value and minus 50px on the y value” also “only work before time is 1 second, otherwise reference whatever keyframes are in the child layer position property.”

    There is probably a better expression than this, but it would work.

    Anyway, just split the layer, ha, it’s better.

    “|_ (°_0) _|”

    Sincerely,

    George

  • Daniele De luca

    March 26, 2015 at 10:15 pm

    There’s also a way to unparent with expression. In some cases that gives you more freedom to manipulate the layer, more than splitting the layer. You only have to put this fix function on the position of the parented layer. When you call it you have to specify the absolute position (that can be keyframed if you use “value” as input) and the layer that you want to unparent, e.g. : fix ( value , thisLayer).

    function fix ( pos , layer ) {
    if (layer.hasParent) {
    var p=layer.parent;
    pos = fix ( pos , p );
    var rp = degreesToRadians(p.rotation);
    var delta = pos - p.position;
    var s = p.scale / 100;
    delta = [ delta[0] / s[0] , delta[1] / s[1] ];
    rad = Math.sqrt ( delta[0]*delta[0] + delta[1]*delta[1] );
    if (delta[1] != 0) ang = Math.atan (delta[0]/delta[1]) else ang = Math.PI/2;
    dx = Math.sin (ang+rp) * rad;
    dy = Math.cos (ang+rp) * rad;
    if (delta[1]&lt;0) {dx=-dx; dy=-dy};
    return [dx,dy] + p.anchorPoint;
    }
    else return pos;
    }

  • Jordan Santiago

    September 17, 2016 at 4:57 am

    Hey there, just wanted to post another resource in case anyone else is having the same problem.

    I was looking for a way to dynamically switch between having one layer be parented to something and then turning it off.
    With this tutorial, you can do just that.

    No “if/else” expression required, you turn it on/off with a slider.

    https://vimeo.com/48790227

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Vimeo framework” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy