Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Using the Y value as the Source Text of a layer, but with a different value

  • Using the Y value as the Source Text of a layer, but with a different value

    Posted by Neto Dal bon on May 23, 2024 at 12:29 am

    Hello everyone!

    I’m working on a sniper game and I need to create some simple UA Video Campaigns on Meta and Google Ads. As I need to have the same video on 3 different aspect ratios, I decided to precomp all my animations and HUD elements, so I can edit them just one time and place where I need.

    This part of the HUD[image 1] is attached to the right side of the screen and shows the scope zoom value, in this case it goes from 0.0X to 18.0X, it also only shows one decimal number and “x”(0.1x, 0.2x… 17.8x, 17.9x, 18.0x). Sometimes the maximum value can be 20.0x or 100.0x, depends on the video. I’m gonna set the value it manually depending on what is happening on the video.

    Right now I’ve attached the Y value to the number actually shown on my text layer. So I attached the Y value of my RED RECTANGLE to the text layer’s source text. At the start the Y value of my rectangle is 610 but I want it to 0.0x and in the maximum position the Y value is 100 and I want it be 18.0x. My comp is 250×700 pixels.

    I’m just using this on the Souce Text: thisComp.layer(“RED RECTANGLE”).transform.position[1]+”x”;

    What I need is to transform the Y value into a minimum of 0.0x and a maximum of 18.0x, so when the rectangle gets higher the value also gets higher and when the rectangle is on the start position the value is 0.0x, so it proportionally increases from 0.0x to 18.0x instead of getting the actual Y value that’s 610 and 100.

    Thanks in advance, you guys have always been very helpful!

    Brie Clayton
    replied 1 year, 11 months ago
    3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    May 23, 2024 at 1:19 am

    Like this, probably:

    y = thisComp.layer("RED RECTANGLE").transform.position[1];
    n = linear(y,100,610,18,0);
    n.toFixed(1) + "X"
  • Neto Dal bon

    May 23, 2024 at 2:20 pm

    Thank You Very Much Dan! It’s so simple but I couldn’t find this “linear” expressions anywhere.

    Thanks again, problem solved

  • Brie Clayton

    May 23, 2024 at 6:17 pm

    Thank you for this solve, Dan!

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