ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Finding the time when a prop reaches a specific value

FAQ   •   VIEW ALL
 Finding the time when a prop reaches a specific value on Jun 2, 2017 at 2:56:52 am

Finding the time when a prop reaches a specific value.

Cheers

TypeGEMs - the Definitive Type Gizmo for AE

Intensive mocha & AE Training in Singapore and Other Dangerous Locations
Imagineer Systems (mocha) Certified Instructor

 Re: Finding the time when a prop reaches a specific valueon Jun 2, 2017 at 12:55:34 pm

There are a number of ways to approach it, all of which are messy and involve a frame-by-frame search. The best solution depends on whether you need the first occurrence, the most recent occurrence, or all occurrences, and whether the value will be coming from above the target value, below the target value, or either.

Dan

 Re: Finding the time when a prop reaches a specific valueon Jun 2, 2017 at 1:08:23 pm

But Dan, we mostly love only messy stuff. ☺

I think based on all occurrences and from both above or below (the value) will provide an ideal/robust solution. I feel that the robustness of the solution will more than make up for the slow compute times of the Expressions.

Cheers
- Roland

TypeGEMs - the Definitive Type Gizmo for AE

Intensive mocha & AE Training in Singapore and Other Dangerous Locations
Imagineer Systems (mocha) Certified Instructor

 Re: Finding the time when a prop reaches a specific valueon Jun 2, 2017 at 1:24:55 pm

Ugh. So what would the result look like?

Dan

 Re: Finding the time when a prop reaches a specific valueon Jun 2, 2017 at 1:53:52 pm

This is what I have now. It's of course incomplete.
I want a layer to inherit specific colors based on the value of a rotation prop. I don't want the color values to pop (change immediately) but instead to have a slow change of the colors. Hence, I thought I would use the Interpolation Method.

targetProp = thisComp.layer("Hand").transform.rotation;
targetVal1 = linear(time,0,1,effect("Color Control")("Color"),effect("Color Control 2")("Color"));
targetVal2 = linear(time,0,1,effect("Color Control 2")("Color"),effect("Color Control 3")("Color"));
targetVal3 = linear(time,0,1,effect("Color Control 3")("Color"),effect("Color Control 4")("Color"));

if (targetProp >=0 && targetProp<1001)
{ targetVal1 }
else if (targetProp >= 1001 && targetProp<2001)
{ targetVal2 }
else if(targetProp< 0)
{ targetVal3 }
else {effect("Color Control 4")("Color")}

Sense make?

TypeGEMs - the Definitive Type Gizmo for AE

Intensive mocha & AE Training in Singapore and Other Dangerous Locations
Imagineer Systems (mocha) Certified Instructor

 Re: Finding the time when a prop reaches a specific valueon Jun 2, 2017 at 4:12:41 pm

Wouldn't something like this work?

``` targetProp = thisComp.layer("Hand").transform.rotation; c1 = effect("Color Control")("Color"); c2 = effect("Color Control 2")("Color"); c3 = effect("Color Control 3")("Color"); c4 = effect("Color Control 4")("Color"); if (targetProp < 50) ease(targetProp,-50,50,c1,c2) else if (targetProp < 1050) ease(targetProp,950,1050,c2,c3) else ease(targetProp,1950,2050,c3,c4); ```

Dan

 Re: Finding the time when a prop reaches a specific valueon Jun 2, 2017 at 6:20:11 pm

HAH!!!
I knew my problem solving was a major issue. I've not written Expressions for a while - and it shows.

Thanks Dan!

TypeGEMs - the Definitive Type Gizmo for AE