Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects › Maintain Distance Expression

  • Maintain Distance Expression

    Posted by Jake Smith on January 11, 2013 at 5:18 pm

    Hello!

    I am trying to have 2 layers maintain their distance between each other. So the idea is that if layer A is at 0,0 and layer B is at 500,500. If layer A moves to 100,100 then layer B would move to 600,600 and could never go below or above that 500 offset.

    Does this make sense? Any help would be greatly appreciated!

    Thanks,
    Joe

    Walter Soyka replied 13 years, 8 months ago 4 Members · 6 Replies
  • 6 Replies
  • Kevin Camp

    January 11, 2013 at 5:58 pm

    you could parent layer B to layer A and offset B and set B’s position to 500,500. B will always keep that offset from A.

    but an expression would be pretty simple:

    target = thisComp.layer(“A”); // make sure your layer A’s name is in the “”
    A.position + [500,500]

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Vishesh Arora

    January 11, 2013 at 5:59 pm

    Set the Final Position of both the layers and then parent both to a Null Object(say at [250,0], center of both layers).

    No need of Expression.

    Vishesh Arora
    3D and Motion Graphics Artist
    Films Rajendra

    Blog:
    https://digieffects.wordpress.com

    Demo Reel(3D):
    https://www.youtube.com/watch?v=lHPgIJU_BR8

  • Kevin Camp

    January 11, 2013 at 6:30 pm

    sorry, i just noticed a mistake in the expression… the last line should be:

    target.position + [500,500]

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Jake Smith

    January 11, 2013 at 7:00 pm

    Thank you for the quick responses! I think I might have phrased what I was looking for incorrectly. I think what I’m looking for is a way to keep an object away from another based on a radius.

    I am attaching an image where object B would always stay on the perimeter of the circle. Hopefully this will make a little more sense.

    Thanks!

  • Kevin Camp

    January 11, 2013 at 7:38 pm

    that ups the ante a bit.

    i’m not sure what you want to happen if a or b get within a 500 pixel radius, but would a repel expression work, where either a or b wold push the other out of the way?

    https://colinbraley.com/repel_expressions_tutorial.html

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Walter Soyka

    January 11, 2013 at 8:12 pm

    [Jake Smith] “I am attaching an image where object B would always stay on the perimeter of the circle. Hopefully this will make a little more sense.”

    Rather than mucking with position, let’s use rotation to keep B on the edge of the circle.

    Let’s assume three layers:

    B
    A
    Circle

    where A & Circle are at the center of the comp.

    Create a null object at the center of the comp, and name it Rotator. Parent B to Rotator, and adjust its position such that B sits on the circle. (To sit it at twelve o’clock on a circle of radius 500, you could make its position [0,-500], because the position is now relative to its parent.)

    Tap R on the B layer to reveal its rotation property, and alt-click the stopwatch. Add the following expression:
    -thisComp.layer("Rotator").transform.rotation

    Now, keyframe Rotator’s rotation property however you like. As you adjust it one way, B’s rotation property will automatically adjust the other way, keeping B level and making it appear to travel along the circle’s perimeter.

    Walter Soyka
    Principal & Designer at Keen Live
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    RenderBreak Blog – What I’m thinking when my workstation’s thinking
    Creative Cow Forum Host: Live & Stage Events

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