ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Move Object from pixels every "x" second | Bpm metronome

FAQ   •   VIEW ALL
 Move Object from pixels every "x" second | Bpm metronome by Fu Wushuon Jul 30, 2017 at 5:36:01 am

Hi everyone,

I'm very new to expression in after effects and i was wondering how to change the position of an object every "x" second, for example every sec, the object move to position A to position B ?

I heard there's posterize time, but i don't know how to completely write it. I got the object to slide from A to B, but i just want them to move from A to B.

And at the end of the bar, i would like to loop it. Is it possible ?

It would be like a metronome, every x second, it moves one square :

Thank you for your help !

 Re: Move Object from pixels every "x" second | Bpm metronomeon Jul 31, 2017 at 10:45:48 am

This is a solution, but you`ll have to do some math. Calculate the steps you need until you get to B.
```steps = 5; dist = thisLayer.sourceRectAtTime(time,false).width; sec = 3; tempX = value[0]+(Math.round(time/sec)%steps)*; [tempX,value[1]];```
If you want to move it more than just its own size to the right, just add something to the dist variable. Sec is the interval between the moves in seconds and steps is how many times before repeating. You can add slider to this variables for an easier modify.

Andrei

 Re: Move Object from pixels every "x" second | Bpm metronomeon Jul 31, 2017 at 11:05:54 am

I misscopied the expression:

```steps = 5; dist = thisLayer.sourceRectAtTime(time,false).width; sec = 3; tempX = value[0]+(Math.round(time/sec)%steps)*dist; [tempX,value[1]];```

Andrei