Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Is it possible to have an expression add 150 to the value every frame?

  • Is it possible to have an expression add 150 to the value every frame?

    Posted by Nik Ammerlaan on August 16, 2015 at 1:04 am

    I’m trying to figure out a way so that when value 2 is larger than x, the expression will add 150 to value 1 every frame until the value 2 stops passing the trigger threshold. Is this possible at all with expressions or will I have to manually do it by keyframe?

    Kalleheikki Kannisto replied 11 years ago 2 Members · 3 Replies
  • 3 Replies
  • Kalleheikki Kannisto

    August 16, 2015 at 8:42 am

    Yes. In the simple case:

    v = value;
    if ([pick-whip some property value here] >= 2) {v = v+150};
    v

    As long as both the pick-whipped value and the target value are one-dimensional (not arrays), it will work. Arrays are slightly more involved, but not much.

  • Nik Ammerlaan

    August 16, 2015 at 2:31 pm

    That only seems to add 150 just once. Is there a way to have it repeat or something?

  • Kalleheikki Kannisto

    August 16, 2015 at 4:37 pm

    Oh, sorry, I misunderstood the question: Keep increasing, not just increase once.

    In that case, this would be the code:

    v = value;
    fd = thisComp.frameDuration;
    n=0;
    inc=1;
    while(inc == 1){
    if([pick-whip a property value here].valueAtTime(time-fd*n)>=2){
    n=n+1}else{
    inc = 0}
    }
    value = value + 150*n

    This version keeps increasing value 1 as long as value two>= 2 and resets value 1 to original (or keyframed) value when value 2 falls below 2.

    If you need the value to keep increasing through the whole duration of the footage whenever above the threshold, you’ll need the while loop to check for values for ALL preceding frames in the comp, (until time-fd*n<= 0) and increment n for every frame the condition is met.

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