ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Up and down

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kevin Tosi
Up and down
on Oct 25, 2016 at 11:07:40 am

I'm looking for an expression that would take my y-position and decrease it by my desired amount every 2 frames and then bring it back to the original y-position in the next 2 frames.

I've tried using sin functions but those go below the original y-position, whereas I want my object to stop at the original position and not go past it.

Thanks for the help!


Return to posts index

Dan Ebberts
Re: Up and down
on Oct 25, 2016 at 3:15:49 pm

This should work:


amt = -10;
f = timeToFrames(time);
n = Math.floor(f/2);
if (n%2){
y = linear(time,framesToTime(n*2),framesToTime(n*2+2),amt,0);
}else{
y = linear(time,framesToTime(n*2),framesToTime(n*2+2),0,amt);
}
value + [0,y]



Dan



Return to posts index

Kevin Tosi
Re: Up and down
on Oct 25, 2016 at 3:41:17 pm

Thank you Dan, that worked!


Return to posts index


Kevin Tosi
Re: Up and down
on Sep 4, 2018 at 5:29:56 am

Just figured I'd add in case anyone is ever looking for this expression. Replaced the values with Slider controls so now it's easier to adjust values rather than manually retyping them all in.

x = effect("Slider Control 2")("Slider");
amt = (effect("Slider Control")("Slider"));
f = timeToFrames(time);
n = Math.floor(f/x);
if (n%2){
y = linear(time,framesToTime(n*(effect("Slider Control 2")("Slider"))),framesToTime(n*(effect("Slider Control 2")("Slider"))+(effect("Slider Control 2")("Slider"))),amt,0);
}else{
y = linear(time,framesToTime(n*(effect("Slider Control 2")("Slider"))),framesToTime(n*(effect("Slider Control 2")("Slider"))+(effect("Slider Control 2")("Slider"))),0,amt);
}
value + [0,y]



Return to posts index

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