FORUMS: list search recent posts

# Expression

FAQ   •   VIEW ALL
 Expression on Nov 4, 2015 at 5:32:13 pm

Hi I need some help to make up an expression, I need to make up an expression that when I move a object it will add a value to a plug in, here is the example I have a radar dot on screen i what to move the dot position upwards and when I move the position upwards I want the value of a Plug in called numbers to increase the Numbers up as well but I only want the value of the numbers to go between certain numbers which will be 0.0 to 10.0 can anybody help! I understand I need a Clamp expression on the numbers but I don't know how write it.

 Re: Expressionon Nov 4, 2015 at 6:16:41 pm

What's the relationship between the position and the number value? I mean, is there a position that corresponds to 0.0 and another that corresponds to 10.0 or are you after something else?

Dan

 Re: Expressionon Nov 4, 2015 at 6:32:01 pm

Yes there is the 0value is on the y position is 270

 Re: Expressionon Nov 4, 2015 at 6:38:16 pm

What corresponds to the 10.0 value?

 Re: Expressionon Nov 4, 2015 at 6:47:03 pm

value 10 would equal 165 which is going down so I would need the numbers to go up

 Re: Expressionon Nov 4, 2015 at 6:51:56 pm

Like this then:

minY = 165;
maxY = 270;
linear(y,minY,maxY,10,0);

Dan

 Re: Expressionon Nov 4, 2015 at 7:55:18 pm

worked a treat! but now I need to position the radar dot in the middle which is y position 270 and now I need to move the dot down to position 394 and have the numbers move between 0 and 10 again

So the Radar dot moves between 270 middle to 165 top and the numbers go from 0 to 10 then (which you gave me the expression to many thanks)
and then move the Radar Dot from 270 middle to 394 bottom and the numbers again go from 0 to 10 again

 Re: Expressionon Nov 4, 2015 at 9:17:00 pm

Like this maybe:

``` minY = 165; midY = 270; maxY = 394 y = thisComp.layer("Radar Dot").transform.position[1]; if ( y > 270) linear(y,midY,maxY,0,10) else linear(y,minY,midY,10,0); ```

Dan