Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Looping an “if” expression

  • Looping an “if” expression

  • Daniel Nye

    November 18, 2019 at 12:56 pm

    Hi,

    I have two keyframes, one of which is controlled by a slider. That works perfectly.

    But I want the animation to loop back and forth, similar to the loopOut(“pingpong”) expression. Obviously if I put this at the end of the expression, it nullifies everything else.

    Does anyone know how I could get by this?

    if (numKeys > 1){
    t1 = key(1).time;
    t2 = key(2).time;
    v1 = thisComp.layer("Slider").effect("value")("Slider");
    v2 = 0;
    linear(time,t1,t2,v1,v2);
    }else
    value

    Thank you!

  • Oleg Pirogov

    November 18, 2019 at 6:52 pm

    How about:
    if (numKeys > 1){
    t1 = key(1).time;
    t2 = key(2).time;
    v1 = thisComp.layer("Slider").effect("value")("Slider");
    v2 = 0;

    t = time<=t2 ? time : (Math.floor((time-t1)/(t2-t1)) % 2 === 0 ? t1+((time-t1) % (t2-t1)) : t2-((time-t1) % (t2-t1)));

    linear(t,t1,t2,v1,v2);
    }else
    value

  • Daniel Nye

    November 19, 2019 at 11:41 am

    Amazing, that works perfectly!

    Thanks.

Viewing 1 - 3 of 3 posts

Log in to reply.

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