Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions maintaining the start value

  • maintaining the start value

    Posted by Josh Holdens on June 25, 2014 at 1:25 am

    Ok, this may be an easy one but for me, it’s a little more than tricky. I know what I’m attempting to do it’s just…. Well here goes the problem. I want to have my opacity change from value – value (in this case 100 – 0),keyed, and then duplicate the layer and have the end decrease by a given value. In my example I use 7. Also I want to be able to keep the valueAtTime aspect in this set up. While building this I noticed that as long as my start value is 100, well it will stay the same and everything works as expected. The question arose “what IF my start value is not 100. So the solution of using some sort of conditional statement in tandem with a linear expression and trying to access key(1) and key(2)came to mind. This thought process only comes from other expressions I’ve seen and my knowledge in the area is limited at best. Hopefully this makes sense. The expression below is where I got to, this portion works. The idea and what I’m trying to do is control the start value. In this setup, behind the scenes I’m getting a value range from 107 – 7 when I duplicate. I want 100 to stay 100(or a value that I specify) and the end value to incrementally change; In this case 7,14,21 etc… There is one caveat, if the solution is a conditional with the linear setup, the issue is on the duplicate layers I want to keep my animation curve that I’ve set on the original layer in the Graph Editor so that the duplicates follow(valueAtTime)…. I really hope this makes sense. Thanks in advance

    thisComp.layer(index + 1).transform.opacity.valueAtTime(time - .15) + 7

    Josh Holdens replied 11 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Kevin Camp

    June 25, 2014 at 7:57 pm

    i think what you are looking for is Math.min(), a function that will take the smaller of two values…
    max = 80; //set maximum value
    o = thisComp.layer(index + 1).transform.opacity.valueAtTime(time - .15) + 7
    Math.min(o,max)

    in this expression, the opacity would never exceed 80. you can set that max value as needed.

    there’s also a Math.max() function which takes the greater of two values, if you ever needed that. and there’s clamp() which can be used to keep a value between 2 values… say you opacity value needed to stay between 20 and 80, clamp(o, 20, 80) would do that.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Josh Holdens

    June 25, 2014 at 8:58 pm

    Thanks A ton! great success with this. I guess I was over complicating it. Again Thanks and thanks again!

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