Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Kevin Tosi on October 25, 2016 at 11:07 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!

    Kevin Tosi replied 7 years, 8 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    October 25, 2016 at 3:15 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

  • Kevin Tosi

    October 25, 2016 at 3:41 pm

    Thank you Dan, that worked!

  • Kevin Tosi

    September 4, 2018 at 5:29 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]

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy