It sounds like you want something like the old Motion Math spring script. George Polevoy posted an expression a few years ago that works pretty well:
// AE expression by George Polevoy
// http://www.creativecow.net
// attaches an object to a “Controller” object with a “spring”
// You need another “Controller” which will drive animation of this one
// parameters
conserveMotion = 0.95; // valid range: 0.5 to 0.995
springResistance = 10; // positive values
prerollTime = 2; // value in seconds. greater values give more precise result
//
fps = 1.0 / this_comp.frame_duration;
if ( prerollTime > time ) prerollTime = time;
dt = this_comp.frame_duration;
frame = time * fps;
integrationTime = time – prerollTime;
s = [0,0];
p = this_comp.layer(“Controller”).position.value_at_time( integrationTime );
i = frame – prerollTime * fps;
for (; i < frame; i++, integrationTime += dt )
{
c = this_comp.layer("Controller").position.value_at_time( integrationTime );
d = c - p;
s = s + d * springResistance;
s = s * conserveMotion;
p = p + s * dt;
}
Dan
Activity