Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Position Expression

  • Position Expression

    Posted by Esuss35 on May 21, 2007 at 11:14 pm

    Hi,

    I’ve tried searching for answers to this question in the forums with no luck.

    What i’m trying to do is loop an animation of a car moving forward on the x axis over 1 second, then pausing for 3 seconds, then moving forward again. the only thing i really use expressions for at the moment is simple linking, wiggle, and looping. i have no idea how to accomplish something that would tell a layer to add value to x between 0-1 seconds, pause for 3 seconds, then add value again over 1 seconds time.

    i hope this makes sense. if it helps, i’m hoping to create a row of cars in rush hour traffic, learching forward for one second, then pausing for three, then hopefully(if someone knows how this can be accomplished) looping the keyframes so that the car continues to move forward again and again.

    thanks,
    evan

    Dan Ebberts replied 18 years, 12 months ago 3 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    May 21, 2007 at 11:43 pm

    Here’s what you could do.

    Step 1:

    dist=500;
    t=time%4;
    travel = ease(t,0,1,0,dist);
    value+[travel,0];

    Use the modulo % operator so time is always between 0 and 4 seconds.
    Between time 0 and 1, the distance increases from 0 to 500. between 1 and 4: nothing happens.
    Now at time=4, the car would jump back to the start and in 1 second would again move the 500 pixels.
    This would be the kind of motion you want to ‘loop’, but we don’t want the car to jump backwards.

    So, what we need is to add an offset at the exact point it jumps back. This offset has to increase every 4 seconds:


    dist=500;
    t=time%4;
    travel = ease(t,0,1,0,dist) + Math.floor(time/4)*distance;

    value+[travel,0];

    Just divided the time by 4, and round down: we get a counter that adds every 4 seconds. Multiply by the distance we would normally jump back at 4 seconds and the counter and jump cancel each other out.

    you can swap the ease for a linear if you like.

    I haven’t tested this code though.

  • Esuss35

    May 22, 2007 at 12:12 am

    Thanks Filip. Its so close! using your first expression, with the layer linked to a null that has your second expression – the car moves forward and stops, then moves forward again. the only thing is that it jumps backwards noticeably before moving forward again. any ideas on how to make it not do that?

    thanks so much,

    evan

  • Dan Ebberts

    May 22, 2007 at 1:08 pm

    I think you only need Filip’s second expression. There is a typo in the third line (which you probably caught) – “distance” should be “dist”.

    Dan

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