# 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

• # Move layer x pixels every nn frames

5 Members · 9 Posts
• ### Navarro Parker

January 20, 2016 at 11:04 pm

would like to move my layer’s position by an artbitrary amount of pixels in +x direction in a certain period of time.

Ideally, it would go something like this: Every half second, add nn to the x position of a layer using hold interpolation.

Or every 12 frames, jump the position xx pixels to the right.

So there would be a continuous progressive jumpy scroll to the right.

• ### Dan Ebberts

January 20, 2016 at 11:25 pm

This should work:

tStep = framesToTime(12);
jumpX = 10;
nSteps = Math.floor((time-inPoint)/tStep);
value + [nSteps*jumpX,0]

Dan

• ### Mikhail Vasilev

January 21, 2016 at 11:44 am

Hi Dan.
And how about random time and distance intervals ?
And smooth(ease) movement? : )

• ### ido shor

July 31, 2016 at 2:10 pm

it would be great if you can add a smooth interpolation between “keyframes” to this expression.

• ### Dan Ebberts

July 31, 2016 at 6:10 pm

Maybe like this:

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

Dan

• ### ido shor

July 31, 2016 at 6:20 pm

Tnx…. works like a charm. 🙂

• ### Víctor Sanz

May 22, 2020 at 4:28 pm

That’s sweet. It would be posible to add a pause between those jumps??
Thank you

• ### Dan Ebberts

May 22, 2020 at 5:35 pm

Like this maybe:

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

Dan

• ### Víctor Sanz

May 22, 2020 at 7:53 pm

It works perfectly!! Thank you very much Dan. Cheers

Viewing 1 - 9 of 9 posts