Copy link to clipboard
Copied
I have a layer that I need to move based on a number that gets calculated each frame. That number is added or removed from the position, but if you do something like this:
[value[0]+10, value[1]]
... you end up with 10 added to the original position, not the position that resulted from previous expressions. Is there a simple way to retain the calculated position? I've always worked using time to get a procedurally generated position, but that's not going to work in this case.
Copy link to clipboard
Copied
Expressions have no way to access their own calculated values from previous frames. If you can't base it on time (although your example could be done with something like this):
value + [10*timeToFrames(time),0]
you can have the expression loop through time frame-by-frame to recreate previous results to be used in the current frame's calculation. Not particularly efficient, but it does work.
Dan
Copy link to clipboard
Copied
Yeah, that's what I was worried about. Essentially what I was trying to do was drive a Particular position in a new random direction every x frames, but I'm not sure how I'd do it procedurally if I can't keep track of an evolving position. AE really needs persistent global variables, though I understand that's way easier said than done.
Copy link to clipboard
Copied
It's not too bad if x is a constant number of frames. You can loop through all the previous x-frame segments, and calculate the ending position for that segment (based on the starting position for the previous segment), which will give you starting position for the current segment.
Dan
Copy link to clipboard
Copied
I can't write it in my head, and I'm replying from a smart phone, but you can do this with value at the time expressions. If I get a chance later today I will write one up.