Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions relational movement without the initial jump

  • relational movement without the initial jump

    Posted by Sam Mattson on June 9, 2014 at 9:36 pm

    I’ve probably just been looking at this too long. I’m sure this is a simple fix.

    Example: 2 nulls in a comp positioned anywhere. Null 1 and Null 2. I have this code applied to the position of Null 1. The code tells Null 1 to move in X as Null 2 moves in Y.
    However, when applying this script, Null 1 jumps its initial position X to match Null 2’s Y. I want Null 1 to keep its initial position and not jump, regardless of where Null 2 started.

    xPos=transform.position[0]+(thisComp.layer("Null 2").transform.position[1] - transform.position[0]);
    yPos=transform.position[1];
    [xPos, yPos]

    Dan Ebberts replied 11 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Sam Mattson

    June 9, 2014 at 10:03 pm

    On other words, I know I can write it like this:

    variance = 640-thisComp.layer("Null 2").transform.position[1];
    xPos=transform.position[0]+variance;
    yPos=transform.position[1];
    [xPos, yPos]

    But I’d like to not have to type the manual value of “640” in if I applied this script to something else with a different Y value.

  • Dan Ebberts

    June 9, 2014 at 10:29 pm

    I think you’re after something like this:

    p = thisComp.layer(“Null 2”).transform.position;
    y = p[1] – p.valueAtTime(0)[1];
    value + [y,0]

    Note that it won’t do anything until you animate Null 2.

    Dan

  • Sam Mattson

    June 10, 2014 at 3:02 am

    I had coded that too, but I was hoping to find the initial position without looking at time, as the nulls I’ll be moving are on a character rig. Oh well, I guess I’ll hand enter the initial values.

  • Dan Ebberts

    June 10, 2014 at 3:14 am

    Yeah, one way or another, you need a reference point for Null 2.

    Dan

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