Page 1 of 1

Train Chain join

Posted: June 11th, 2010, 2:05 am
by sameervalva
Hi,

I'm wondering if there is a script or a expression to link layers together as a train. I have the Train Layers and i want to join them to move as a train following the leader on its path without interfering or intersecting with other layers.

Re: Train Chain join

Posted: June 11th, 2010, 1:48 pm
by kobyg
In general what you are looking for is a very complicated expression...
However, if you limit the movement of the train to constant speed, that could be much easier!
Use "Rove Across Time" keyframes in the leader position, in order to achieve a constant speed
and then use an expression like this for all layers below the leader:

Code: Select all

dt = thisComp.layer("Null 1").effect("dt")("Slider");
indx = index - 2;  // 2 is the index of the leader layer
thisComp.layer("Leader").transform.position.valueAtTime(time - dt*indx)
Where "dt" is the time difference you want the "followers" to follow the leader.
(note that constant time difference at a constant speed would lead a constant distance between layers, which is what you want)
Tweak the "dt" value using a slider (like I did in the expression above) until you have the desired space between layers.

See attached example animation I've made, using the above method.

Enjoy,
Koby