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 for a value to only be influenced by rising input?

  • Is it possible for a value to only be influenced by rising input?

    Posted by Jon Wooley on May 21, 2013 at 6:50 pm

    I hope I titled that right. I’ve searched the forums but haven’t found anything, perhaps because I’m not using the right terminology.

    The problem is simply this, can and how would I write and expression that rises when the input it’s referencing rises, but stays static when that referenced input lowers?

    I’ve included the code I’m using currently below. Predictably, it resets to 0 when the referenced value decreases. I would like it to stay at the last value it was at, rather than resetting. Basically it would be as if the downward shift never occurred.

    Thank you all in advance.

    x = value[0];
    y = value[1];
    rot = thisComp.layer("Null 1").transform.rotation;
    rotPast = rot.valueAtTime(time-1);

    if (rot - rotPast >= 0){
    rise = rot
    }else{
    rise = 0
    }

    ny = y + (rise*-10);

    [x,ny];

    Jon Wooley replied 12 years, 12 months ago 3 Members · 3 Replies
  • 3 Replies
  • Mitch Mann

    May 21, 2013 at 7:30 pm

    Here’s a calculation-intensive idea: Loop through every previous frame to find the “highest yet” value, and there you go. That way the value would only ever rise.

    Pretty calculation-intensive because you’d have to recalculate everything on every frame, so for a long comp it could get pretty slow. You could probably get a similar result by only calculating every 3 frames in previous time, instead of every frame.

  • Dan Ebberts

    May 21, 2013 at 7:35 pm

    There’s no way to do it directly, you have to analyze each previous frame. Something like this should work:

    accum = 0;
    rot = thisComp.layer(“Null 1”).transform.rotation;
    for (f = timeToFrames(inPoint); f <= timeToFrames(time); f++)
    if (rot.speedAtTime(framesToTime(f)) > 0) accum -= 10;
    value + [0,accum]

    Dan

  • Jon Wooley

    May 21, 2013 at 7:54 pm

    Thank you both!

    Dan your solution worked perfectly.

    I cannot thank you enough. You are a genius and a credit to this and many other communities.

    Thank you so much!

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