ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Looping an "if" expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Daniel Nye
Looping an "if" expression
on Nov 18, 2019 at 12:56:32 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!


Return to posts index

Oleg Pirogov
Re: Looping an "if" expression
on Nov 18, 2019 at 6:52:12 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


Return to posts index

Daniel Nye
Re: Looping an "if" expression
on Nov 19, 2019 at 11:41:34 am

Amazing, that works perfectly!

Thanks.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]