ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Maintain Distance Expression

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jake SmithMaintain Distance Expression
by on Jan 11, 2013 at 5:18:34 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


Return to posts index

Kevin CampRe: Maintain Distance Expression
by on Jan 11, 2013 at 5:58:21 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


Return to posts index

Kevin CampRe: Maintain Distance Expression
by on Jan 11, 2013 at 6:30:15 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


Return to posts index


Vishesh AroraRe: Maintain Distance Expression
by on Jan 11, 2013 at 5:59:37 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:
http://digieffects.wordpress.com

Demo Reel(3D):







Return to posts index

Jake SmithRe: Maintain Distance Expression
by on Jan 11, 2013 at 7:00:03 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!



Return to posts index

Kevin CampRe: Maintain Distance Expression
by on Jan 11, 2013 at 7:38:30 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?

http://colinbraley.com/repel_expressions_tutorial.html

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW


Return to posts index


Walter SoykaRe: Maintain Distance Expression
by on Jan 11, 2013 at 8:12:58 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]