ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Revert value to zero once to comp edge

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jim Johnston
Revert value to zero once to comp edge
on Mar 18, 2018 at 5:33:55 am
Last Edited By Jim Johnston on Mar 18, 2018 at 5:38:11 am

Hey all. I have a position expression which moves in a certain direction each frame as follows (thanks to Dan Ebberts).

spd = effect("Slider Control")("Slider");
angle = effect("Angle Control")("Angle");
d = spd*(time-inPoint);
r = degreesToRadians(angle);
x = d*Math.cos(r);
y = d*Math.sin(r);
value + [x,y]


But I need the x and y values to reset to 0 once they reach a certain threshold (such as the comp width/height).

I tried adding if(x>100) x=0;
which works but keeps the value of x at 0 for the remainder..

Something really simple I suspect but not getting anywhere at the moment!


Return to posts index

Jim Johnston
Re: Revert value to zero once to comp edge
on Mar 18, 2018 at 6:11:36 am

Figured it out. AE doesnt store variables over time apparently. So a modulus function works instead just fine I think

spd = effect("Slider Control")("Slider");
angle = effect("Angle Control")("Angle");
d = spd*(time-inPoint);
r = degreesToRadians(angle);
x = d*Math.cos(r);
y = d*Math.sin(r);
value + [x%1280,y%720]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]