ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Up and down

FAQ   •   VIEW ALL 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! Re: Up and downon 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 Re: Up and downon Sep 4, 2018 at 5:29:56 am
```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] ```