Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Looping range of keyframes set times, then complete following keyframes

  • Looping range of keyframes set times, then complete following keyframes

    Posted by Ash Curkpatrick on November 19, 2014 at 11:44 pm

    Hi, I’m still wrapping my head around the basics of expressions and loops and I’m trying to work out if there is a way that I can create an expression where I can loop two intial position keyframes for a set amount (let’s say 5 loops), then once the loops are completed, continue to the next set of keyframes.

    Sorry if this is sort of vague. Below is an expression I’ve found elsewhere before that I thought I could try to modify to some degree, but I’m still having a bit of difficulty

    var loops = 2; // loop it two times
    var range = key(numKeys).time - key(2).time; // length of our range
    (time > key(1).time + range * loops) ? transform.position : loopOut("cycle",0);

    Ash Curkpatrick replied 11 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    November 20, 2014 at 12:01 am

    Something like this maybe:


    if (numKeys > 1){
    nLoops = 5;
    t1 = key(1).time;
    t2 = key(2).time;

    if (time < t1)
    value
    else if (time < t1 + nLoops*(t2-t1))
    valueAtTime(t1 + (time - t1)%(t2-t1))
    else
    valueAtTime(t2 + time - (t1 + nLoops*(t2-t1)));
    }else
    value

    Dan

  • Ash Curkpatrick

    November 20, 2014 at 12:55 am

    Thanks so much! Exactly what I needed!

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