ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Moving an Object Relative to Others

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tynan "just the right amount of fingers" Humphrey
Moving an Object Relative to Others
on Jan 19, 2018 at 1:25:56 am

Hi!

I have a cloud of 2D layers spread across 3D space. The front/center layer is the controller. I used this tutorial as an entry point substituting position for scale. What I want instead is for the layers to move relative to the objects around them. Does that make sense? If the object in the top left of the cloud moves toward the center object, all objects between the two shift proportionally. That said, ideally the initial position is set with the layer's position value, not procedurally generated by the expression.

Any pointers would be amazing!
Thanks.


Return to posts index

Kalleheikki Kannisto
Re: Moving an Object Relative to Others
on Jan 20, 2018 at 12:53:51 pm

Not quite picturing what you want to achieve. An image would help.

Do you want two of the layers to control the motion (the "center one" and the last one)? Are the rest in a straight line in between?

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Tynan Humphrey
Re: Moving an Object Relative to Others
on Jan 23, 2018 at 5:55:37 am

Here's the expression I ended up using. It scales well and seems fairly lightweight. Let me know if you see any optimizations.

//Initial position variables
initCtrl1=thisComp.layer("Ctrl1").transform.position.valueAtTime(-1);
initCtrl2=thisComp.layer("Ctrl2").transform.position.valueAtTime(-1);
objPos=transform.position;

//Current positions variables
newCtrl1=thisComp.layer("Ctrl1").transform.position;
newCtrl2=thisComp.layer("Ctrl2").transform.position;

//Measurements
oldDistance = initCtrl1-initCtrl2;
newDistance = newCtrl1-newCtrl2;
xRatio = newDistance[0]/oldDistance[0];
yRatio = newDistance[1]/oldDistance[1];

//Adds relative movement to the 0 value controller
newPos=[newCtrl2[0]+objPos[0]*xRatio, newCtrl1[1]+objPos[1]*yRatio];


Return to posts index

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