Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions constrain position to x axis

  • constrain position to x axis

    Posted by Joseph Pole on July 15, 2009 at 10:26 am

    i’m sure this is an easy one but…

    i want to have one layer move on the x axis and another layer do the same in the opposite direction

    have added a null and linked both layer’s x positions to that and tried *-1 on the one i want to move opposite but no luck.

    appreciate any help

    thanks

    Dan Ebberts replied 16 years, 10 months ago 3 Members · 2 Replies
  • 2 Replies
  • Filip Vandueren

    July 15, 2009 at 1:11 pm

    For layers that are not patented, try Something like this:

    p=thisComp(“layer”).position;
    w=thisComp.width;

    [w-p[0],p[1]];

  • Dan Ebberts

    July 15, 2009 at 1:41 pm

    There are a couple of possibilities. If you want your layers to move based on movement of the null, you can apply expressions like these:

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

    and

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

    This causes one layer to mimic any keyframed movement of the null in the x direction and the other layer will go the opposite direction.

    That may not be what you meant though (this doesn’t do anything until you keyframe some movement of the null). Another possibility would be to have the layers move in response to the Null’s distance from a fixed point.

    Let’s say you want the layers to respond to the null’s distance from the center of the comp. That would look like this:

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

    and p = thisComp.layer(“Null 1”).transform.position;
    x = p[0] – thisComp.width/2
    value – [x,0]

    Dan

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