Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to link with relative values?

  • How to link with relative values?

    Posted by Mateo Mazzini on October 20, 2016 at 2:41 pm

    I have one object with position and scale animated, and I want another object to follow the position of the first object but not the scale, is there a way to link the position of the second object to the position of the first but in a relative way, as if were the “parent”?. Because if I put “thisComp.layer(“object1″).transform.position”, it copies the position of the first object, and I want it to retain it´s original position while following the parent.
    I know I can do this with a null object in the middle, but I think there must be a workaround on this, and I just don´t know it.

    thanks.

    Matz

    Dan Ebberts replied 2 years, 9 months ago 4 Members · 8 Replies
  • 8 Replies
  • Romain Cousin

    October 20, 2016 at 3:19 pm

    I think you can write this expression on the position of your follower layer :

    thisComp.layer("NAME OF THE "PARENT" LAYER").transform.position+value;

    Freelance motion designer :
    http://www.romaincousin.fr

  • Dan Ebberts

    October 20, 2016 at 4:02 pm

    Try this:

    p = thisComp.layer(‘NAME OF THE “PARENT” LAYER’).transform.position;
    (p.value – p.valueAtTime(0)) + value;

    Dan

  • Romain Cousin

    October 20, 2016 at 4:22 pm

    Nice! I really need to learn how to use valueAtTime…

    Freelance motion designer :
    http://www.romaincousin.fr

  • Mateo Mazzini

    October 20, 2016 at 4:39 pm

    Thanks a lot Dan! that does exactly what I needed.
    Is there a way to go further and make this expression work when you link at the middle of an animation?.
    I was playing with nearestKey(time) but I didn’t accomplish anything so far.

    Matz

  • Dan Ebberts

    October 20, 2016 at 5:43 pm

    If you wanted to attach to the parent at a particular keyframe, you could do it like this:


    p = thisComp.layer('NAME OF THE "PARENT" LAYER').transform.position;
    keyToStart = 2;
    if (p.numKeys > (keyToStart-1)){
    t = p.key(keyToStart).time;
    if (time > t){
    value + (p.value - p.valueAtTime(t))
    }else{
    value
    }
    }else
    value

    Or, it you wanted to be at a particular time, you could do this:


    p = thisComp.layer('NAME OF THE "PARENT" LAYER').transform.position;
    tStart = 2;
    if (time > tStart)
    value + (p.value - p.valueAtTime(tStart))
    else
    value

    Dan

  • Mateo Mazzini

    October 21, 2016 at 1:17 pm

    these two codes are amazing! thanks a lot Dan!

    Matz

  • Gustavo Saliola

    August 6, 2023 at 8:58 pm

    Hi Dan! As usual, and trough time, thanks for your kind and resourceful answers! In my case, I’m trying to parent paint clone strokes “clone position” and “position” to a null’s position, but maintaining both actual values, so I don’t have to manually adjust the paint work done.

    I know in my gut that it can’t be too difficult, but having googled for 2 hrs. and found myself here again, I think there’s hope.

  • Dan Ebberts

    August 6, 2023 at 11:00 pm

    I’m having a hard time picturing what it is that you’re asking. Can you provide more detail?

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