Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Limiting Values

  • Posted by Shawn Romano on September 29, 2008 at 4:10 pm

    Although I have been using super-basic expressions in AE for some time, I am just now starting to really dig in. I just purchased Harry Frank’s expressions training from Toolfarm, and it was great but it did not get into what I am trying to figure out. Here’s my problem:

    I have a 3d map layer that I am zooming in and out of with a camera, and I have a bunch of 3d “beacon” layers that mark specific points on the map. When I am zoomed way out, the dots are too small to see. If I make them bigger then they are too big when I zoom in. I have attempted to link their scale to the Z position of my camera, which sort of worked but did not give me enough control.

    What I really want to do is link the beacon layers’ scale to the camera’s Z position, but limit the minimum and maximum values that the beacons will scale to. That way when I zoom way out, after a certain point they will not get any smaller, and when I zoom way in, after a certain point they will not get any bigger. If I can do this it will save me a ton of headaches…

    Thanks so much.

    Shawn Romano replied 17 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    September 29, 2008 at 8:28 pm

    Assume that you’ve already calculated the distance from the camera and stuffed it into variable “d”.

    Then you can do something like this, which will clamp the scale’s values between minScale and maxScale:

    minScale = [10,10];
    maxScale = [200,200];
    dAtMinScale = 1000;
    dAtMaxScale = 100;

    linear(d,dAtMaxScale,dAtMinScale,maxScale,minScale)

    Dan

  • Shawn Romano

    September 29, 2008 at 9:18 pm

    Thanks so much Dan! With a bit of tweaking, this is working quite nicely. Here’s what I ended up using:

    d = thisComp.layer(“Camera 1”).transform.position[2];

    minScale = [1.5, 1.5];
    maxScale = [100, 100];
    dAtMinScale = -7000;
    dAtMaxScale = 10;

    linear(d,dAtMaxScale, dAtMinScale, maxScale, minScale)

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