Copy link to clipboard
Copied
Hi,
This expression, put in a NULL.position won't make it move. For the expression is somehow recursive :
newPosition = [] ;
if (time>1) {
lastPosition = thisComp.layer("NULL").position.valueAtTime(time-thisComp.frameDuration);
// filter core :
newPosition[0] = lastPosition[0] + 10 ;
newPosition[1] = lastPosition[1] ;
newPosition[2] = lastPosition[2] ;
}
else {newPosition = [960,540,0] ;}
[newPosition[0],newPosition[1],newPosition[2] ]
Is there a workaround to create an algorithm of this sort : position(n) = f( position(n-1) )
Thanks !
An expression can't access a previous result using valueAtTime(). It only has access to pre-expression values. But you can often overcome this limitation by basing your calculation on time. For example, if you want the layer to move right 10 pixels on each frame, you could do something like this:
f = timeToFrames(time);
value + [f*10,0,0]
Dan
Copy link to clipboard
Copied
An expression can't access a previous result using valueAtTime(). It only has access to pre-expression values. But you can often overcome this limitation by basing your calculation on time. For example, if you want the layer to move right 10 pixels on each frame, you could do something like this:
f = timeToFrames(time);
value + [f*10,0,0]
Dan
Copy link to clipboard
Copied
Everybody would do this with a for-loop, but this is da(m)n clever!
Copy link to clipboard
Copied
Thanks Dan, Thanks Martin,
In fact, my example was purposely basic. What I needed to do was a smoothing of the motion of a NULL to animate another NULL and make it the point of interest of a camera.
I found a workaround ... which is better in fact than the original first order filter I tried to implement :
Thanks !
Find more inspiration, events, and resources on the new Adobe Community
Explore Now