Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Move layer x pixels every nn frames and then stop

  • Move layer x pixels every nn frames and then stop

  • Nihad Spahic

    November 2, 2021 at 2:31 pm

    Hello everyone, I have found on this discussion how to move layer on x-axis every something frames

    https://creativecow.net/forums/thread/move-layer-x-pixels-every-nn-frames/

    I am moving a composition 200 pixels to the left every 10 frames using this expression.

    tStep = framesToTime(10);
    tPause = framesToTime(10);
    jumpX = -200;
    t = time - inPoint;
    nSteps = Math.floor(t/(tStep+tPause));
    phase = t-((tStep+tPause)*nSteps);
    e = linear(phase,0,tStep,0,jumpX);
    value + [nSteps*jumpX + e,0]

    If you could help me how to stop it for example on the 300th frame and leave it in that same position.

    Regards

    Move layer x pixels every nn frames

  • Dan Ebberts

    November 2, 2021 at 4:41 pm

    This would be one way:

    tStep = framesToTime(10);

    tPause = framesToTime(10);

    tStop = framesToTime(300);

    jumpX = -200;

    t = Math.min(Math.max(time - inPoint,0),tStop);

    nSteps = Math.floor(t/(tStep+tPause));

    phase = t-((tStep+tPause)*nSteps);

    e = linear(phase,0,tStep,0,jumpX);

    value + [nSteps*jumpX + e,0]

  • Nihad Spahic

    November 2, 2021 at 9:19 pm

    Thank you so much! Works like a charm!

  • Nihad Spahic

    November 3, 2021 at 6:04 pm

    Hey Dan, is it possible to tell the expression when to start, on which frame?

  • Dan Ebberts

    November 3, 2021 at 6:51 pm

    Like this (adjust tStart to set start frame):

    tStep = framesToTime(10);

    tPause = framesToTime(10);

    tStart = framesToTime(10);

    tStop = framesToTime(300);

    jumpX = -200;

    t = Math.min(Math.max(time - tStart,0),tStop);

    nSteps = Math.floor(t/(tStep+tPause));

    phase = t-((tStep+tPause)*nSteps);

    e = linear(phase,0,tStep,0,jumpX);

    value + [nSteps*jumpX + e,0]

  • Nihad Spahic

    November 3, 2021 at 8:25 pm

    Thanks!

  • Nihad Spahic

    November 4, 2021 at 7:58 pm

    Hey Dan, one more question. I have tried to use it on the Y-axis as well, but when I change to jumpY it stay on an X-axis? Regards

  • Dan Ebberts

    November 4, 2021 at 10:03 pm

    I guess that would look like this:

    tStep = framesToTime(10);

    tPause = framesToTime(10);

    tStart = framesToTime(10);

    tStop = framesToTime(300);

    jumpY = -200;

    t = Math.min(Math.max(time - tStart,0),tStop);

    nSteps = Math.floor(t/(tStep+tPause));

    phase = t-((tStep+tPause)*nSteps);

    e = linear(phase,0,tStep,0,jumpY);

    value + [0,nSteps*jumpY + e]

  • Nihad Spahic

    November 5, 2021 at 6:27 am

    Thank you so much!

Viewing 1 - 9 of 9 posts

Log in to reply.

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