Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions An Alternative to Parenting when Parenting fails

  • An Alternative to Parenting when Parenting fails

    Posted by Jason Hearne on February 2, 2012 at 9:17 pm

    I recently ran across a post by Tim West and answered by Ben Rollason. I replied to it, but fear it may be too old for anyone to actually respond too.

    Here’s the Question that Tim Asked:

    I am trying to create an expression that parents the X & Y position of one null (‘A’) to the X & Y position of another null (‘B’) only – I want to be able to animate the Z postion of null A independently.

    Ben supplied this for a solution:

    L = thisComp.layer("Null B");

    LP = L.toWorld(L.anchorPoint);

    [LP[0], LP[1], value[2]];

    I was hoping this thinking could be applied to a slider on one null controlling the X axis of another. I’ve tried parenting but my Z Expression goes off the deep end.

    • I have Null A with a slider (-100,100). Layer A has a linear expression converting the Coordinates from Null A.
    • Null B is placed randomly in the comp and should be free to move by the artist.
    • I need Null A, Slider at 0, to effect Null B X value in both Directions

    Thanks in advance

    Jason Hearne
    EdenFX
    Visual Effects and Animation

    Jason Hearne replied 14 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Paul Roper

    February 2, 2012 at 9:23 pm

    Create a slider control on Null A; in this case I’ve called it “x_amount”. Create an expression for the position of Null B and paste the following expression into it:

    [thisComp.layer("Null A").effect("x_amount")("Slider"),value[1],value[2]]

  • Jason Hearne

    February 2, 2012 at 11:03 pm

    Thanks for the reply, Paul.

    Unfortunately it doesn’t work right. I need to still be able to independently move the “Null B” by dragging it anywhere I want (hence why in this case, parenting fails). And also I need to be able to control the speed – which is what I was hoping for by using Linear().

    Let’s say I have a bare null at pos[1067,246]. When I apply the expression the null needs to stay where it is and yet then be affected by the slider. This is why I was fooling around with toWorld.

    Jason Hearne
    EdenFX
    Visual Effects and Animation

  • Paul Roper

    February 2, 2012 at 11:30 pm

    If you added the slider value to the value[0] of your null, you could position the null wherever you wanted, then keyframe your slider from 0 to, say 500, then your null would move from wherever you’ve manually put it, to wherever the slider tells it to go. If you get what I mean.

    This expression takes the current position [value[0],value[1]] and adds to the x position – value[0] – whatever the slider is set to.

    But going back to your original point, it sounds like parenting would be perfect for this – if you make Null B the child of Null A, you can place it wherever you like, and then it will also follow Null A. No expressions required.

    offset=thisComp.layer("Null 2").effect("Slider Control")("Slider");
    [value[0]+offset,value[1]]

  • Jason Hearne

    February 3, 2012 at 1:21 am

    Awesome Paul!

    With your help I was able to crack the nut. Since my Null was 3D I needed to have Value[2] as well. And then I just multiplied the offset to a comparable number for the speed.

    And since I knew I could probably replicate the Y axis, I didn’t mention it.

    The resulting expression is below

    x_offset = thisComp.layer("Camera Controls").effect("Mosaic Mover X")("Slider")*30;
    y_offset = thisComp.layer("Camera Controls").effect("Mosaic Mover Y")("Slider")*20;
    [value[0]+x_offset,value[1]+y_offset,value[2]]

    Jason Hearne
    EdenFX
    Visual Effects and Animation

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