Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions loopIn & loopOut a linear() expression

  • loopIn & loopOut a linear() expression

    Posted by Javi Gil on September 30, 2022 at 2:21 pm

    Hi!

    I have this project where I need to have layer markers to determine when the loop point happen. The problem is that it is going to be a lot of duplicated layers with the exact same set up, and I need this to loopIn and loopOut, to still have looping animation before the first marker and after the second one.

    Basically what I need is that if I have the first marker at time=0 and the second one at time=10, I want the timeremap to go from 0secs to 5secs between this two markers, and have it loopIn(“cycle”) and loopOut(“cycle”) with this new animation.

    Right now I have this:

    mark1 = thisLayer.marker.key(1).time;

    mark2 = thisLayer.marker.key(2).time;

    mark0 = mark1-(mark2-mark1);

    pos1= 0;

    pos2=10;

    loopNumber = Math.floor(time/mark2);

    if (mark1>0 && time<=mark1) {

    linear(time, mark0,mark1,pos1,pos2)

    } else if (time<mark2 && time>mark1){

    linear(time,mark1,mark2,pos1,pos2)

    } else {

    mark1 = mark2*loopNumber;

    mark2 = mark2*(loopNumber+1);

    linear(time, mark1,mark2,pos1,pos2)

    }

    But for whatever reason it seems to jump frames at some point, so I can’t make it loop if I offset any of the layers.

    Any idea??

    Thank you!!

    JaviG

    Javi Gil replied 1 year ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 30, 2022 at 2:46 pm

    I think this might be close to what you’re looking for:

    m1 = thisLayer.marker.key(1).time;
    m2 = thisLayer.marker.key(2).time;
    pos1 = 0;
    pos2 = 10;
    d = m2 - m1;
    offset = d - m1%d;
    t = (time + offset)%d;
    linear(t,0,d,pos1,pos2)
  • Javi Gil

    September 30, 2022 at 2:51 pm

    This works like a charm Dan! Thank you so so much!!
    Just so I can understand it, what does the “%” renders?

    Again, thank you SO much!

  • Dan Ebberts

    September 30, 2022 at 3:02 pm

    % gives you the remainder of a division operation. So 10.5%3, for example, would give you 1.5

  • Javi Gil

    September 30, 2022 at 3:10 pm

    oooouh! I see!!

    Thank you again Dan!

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