ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Creating a stretchy chain of objects

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
William Anugerah
Creating a stretchy chain of objects
on Feb 3, 2017 at 3:04:41 pm

Hello,

I'd like to ask for some help, for a rigging purpose I need to have a string of about 4 objects where the middle two (pictured red null) will be constrained between the two end objects (pictured yellow null) in a straight line. It needs to stretch and retain the ratio of distance between the objects and work on all axis.



I will really appreciate it if anyone can enlighten me on how to make this work and the expressions necessary to do so.


Return to posts index

Emre Anil
Re: Creating a stretchy chain of objects
on Feb 3, 2017 at 3:24:26 pm

Assuming t1 and t2 are the Yellow Null Objects:

First Red Null Object's position expression:
n1 = thisComp.layer("t1").transform.position;
n2 = thisComp.layer("t2").transform.position;
pX = n1[0] - ((n1[0] - n2[0]) / 3 * 2);
pY = n1[1] - ((n1[1] - n2[1]) / 3 * 2);
[pX, pY]


Second Red Null Object's position expression:

n1 = thisComp.layer("t1").transform.position;
n2 = thisComp.layer("t2").transform.position;
pX = n1[0] - ((n1[0] - n2[0]) / 3);
pY = n1[1] - ((n1[1] - n2[1]) / 3);
[pX, pY]


Return to posts index

William Anugerah
Re: Creating a stretchy chain of objects
on Feb 3, 2017 at 8:13:47 pm

Thank you very much! While it does exactly what I wanted, it does reposition the middle (red null) objects into equal distances, which is not quite ideal because my objects are initially laid out in a different ratio.

I was able to easily offset the resulting position by adding value to the last line ( [xx+pX, yy+pY] ) until they match their initial position, but is there any other way to work this out while keeping the objects's initial position intact?


Return to posts index


Emre Anil
Re: Creating a stretchy chain of objects
on Feb 4, 2017 at 8:49:21 am

I divided the position difference by 3 for the even spacing. changing it according to your ratio should work.


Return to posts index

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