-
Incorrect layer movement expression
Hi there!
I have such an expression on a position of a layer:
var distance = [0,0];
var p0 = toComp(anchorPoint, 0);
var res = [0,0];
for(var cF = 0; cF < timeToFrames(time); cF++)
{
distance = (thisComp.layer(“Target Layer”).toComp(anchorPoint) – toComp(anchorPoint, time – 0.1)) * 0.5;
res += distance;
}
p0 + resThe idea was that at the first frame the layer would go 1/2 of the distance to a target layer. Next frame 1/4 and etc.
And if I move the target layer the layer with an expression should smoothly change its direction to it.But instead I got an uniform movement of the layer in direction of the target layer.
Is there a mistake in that expression or am I just not understanding how expressions work and, for example, AE can’t let an expression to refer to its state in a previous frame or something like that?