Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions If Then Statement Help

  • If Then Statement Help

    Posted by Dan Seibert on October 14, 2009 at 3:30 am

    Hey everyone.

    I’m looking to make something where layers get closer to the middle of the comp, the closer to a virtual camera in z space. I’m looking an expression to do that. I’ve been playing with the if then statement, but I need a little help understanding how to make it do what I want. Thanks.

    -Dan Seibert

    Xinlai Ni replied 16 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • Xinlai Ni

    October 14, 2009 at 4:51 am

    You don’t need if statement to do this, the thing you need is this expression of the position of the layer:

    xyPos = toComp(thisLayer.position); // project this layer to comp plane
    distToCompCenter = length(xyPos – [thisComp.width / 2, thisComp.height / 2]; // how far this layer is to the comp center
    distToCameraZ = 10 * distTocompCenter; // how far this layer to the camera in Z direction is 10 times of how far it is to the comp center
    [thisLayer.position[0], thisLayer.position[1], thisComp.layer(“Camera”).position[2] + distToCameraZ] // modify this layer’s Z position relative to the camera.

    This is assuming camera is looking at the Z+ direction, if not, you may want to offset the layer along the “look at” direction of the camera.

    Xinlai Ni
    Software Engineer, Google Inc.

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