3 Replies Latest reply on Aug 25, 2017 11:34 AM by Dan Ebberts

# linear function that at end goes back to start value

Hi everyone.

Trying to figure out the best way to create a function that uses a linear(input, min, max, outmin, outmax) setup but, here's the trick: only does that for a specified amount and at the end goes back to the starting value.

I'm planning on using it to control the scale of a layer when a null layer is just above it, when the null layer is past the layer it goes back to the starting state.

As I understand the linear() function it doesn't have a way to define a specific range that the calculation is based on?

Any help is greatly appreciated!

• ###### 1. Re: linear function that at end goes back to start value

You didn't provide much detail, so this is pretty general, but probably something like this:

minDist = 100;

maxDist = 400;

d = length(thisComp.layer("Null 1").position,position);

linear(d,minDist,maxDist,[150,150],value)

Dan

• ###### 2. Re: linear function that at end goes back to start value

Hi Dan!

Yeah, this is exactly what I was trying to achieve!

But I don't really understand why and how it works: do you mind explaining the length function and the setup in general?

• ###### 3. Re: linear function that at end goes back to start value

You can use length() to measure the distance between two layers. Then I just used linear() to scale the layer up as the null approaches. You might want to adjust maxDist (the distance where the null has no effect) and minDist (where the null has the maximum effect).

Dan