ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Creating a stretchy chain of objects

FAQ   •   VIEW ALL
 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.

 Re: Creating a stretchy chain of objectson 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]```

 Re: Creating a stretchy chain of objectson 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?