Train Chain join

What type of scripts do you need?

Moderator: byronnash

Post Reply
Posts: 4
Joined: May 21st, 2010, 2:39 am


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.
Posts: 128
Joined: December 7th, 2007, 10:11 am

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.

(4.69 KiB) Downloaded 524 times
Post Reply