Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions keep scale positive

  • keep scale positive

    Posted by Peter Zeet on October 8, 2012 at 2:36 pm

    hi!
    I am using this follow the leader with delay code

    e=thisComp.layer("lead").transform.scale;
    d=thisComp.layer("lead").effect("delay")("Slider")*thisComp.frameDuration*(index - 1);
    e.valueAtTime(time - d);

    How could I prevent the scale (of the follower layer) from going negative so when the scale is negative make it 0?

    thanks!

    Pete.

    Peter Zeet replied 13 years, 9 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    October 8, 2012 at 3:15 pm

    Try changing the last line to this:

    s = e.valueAtTime(time – d);
    [Math.max(s[0],0),Math.max(s[1],0)]

    Dan

  • Peter Zeet

    October 8, 2012 at 3:39 pm

    great!! thanks!

    Now I`m adding +value

    s = e.valueAtTime(time - d);
    sm=[Math.max(s[0],0),Math.max(s[1],0)];
    sm+value

    so I can rescale down some followers… but no it doesn`t seem to work
    (Now I have some follower layer with scale [-30,-30] when Lead is [0,0], so when lead is [100,100] Follower is [70,70], ans similar with other followers.. but as I added the “+value”, theMath.max thing seems not to work (when lead 0, follower keep being on -30)

  • Dan Ebberts

    October 8, 2012 at 3:55 pm

    I’m confused. I don’t see how the follower could ever have a negative scale unless the leader does. What is the relationship between leader and follower that you’re trying to establish? I’m guessing that you might need to be multiplying instead of adding but I’m not sure.

    Dan

  • Peter Zeet

    October 8, 2012 at 4:24 pm

    yes! this is image is a portion of the thing (is a big big graphic full of branches like these. Note the leader. Is scaled 100%.

    (The leader has a bounce expression there).

    Look at the followers shorter than the leader…
    Using the first expression, if followers have scale= 0, they will follow leader`s scale exactly, right? ,but I wanted the followers to have smaller scales than 100% when the Leader is 100%.
    So I added the + value and added negative start on their scale values so when they reach the leader 100%, they are 70%, 80%, ecc. (making them having a -30 as value instead of 0)

    Definetely a bad approach I guess. It worked until I wanted to go deeper…

  • Dan Ebberts

    October 8, 2012 at 5:56 pm

    More like this, probably:

    e=thisComp.layer(“lead”).transform.scale;
    d=thisComp.layer(“lead”).effect(“delay”)(“Slider”)*thisComp.frameDuration*(index – 1);
    s = e.valueAtTime(time – d);
    [value[0]*s[0],value[1]*s[1]]/100;

    Dan

  • Peter Zeet

    October 8, 2012 at 7:25 pm

    Dan, you are the light that makes the darkness dissapear

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