FORUMS: list search recent posts

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

FAQ   •   VIEW ALL
 Is it possible for a value to only be influenced by rising input? on May 21, 2013 at 6:50:55 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.

```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]; ```

 Re: Is it possible for a value to only be influenced by rising input?on May 21, 2013 at 7:30:42 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.

 Re: Is it possible for a value to only be influenced by rising input?on May 21, 2013 at 7:35:13 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

 Re: Is it possible for a value to only be influenced by rising input?on May 21, 2013 at 7:54:02 pm

Thank you both!