Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Text Counter Connected to Layers Z-Rotation

  • Text Counter Connected to Layers Z-Rotation

    Posted by Doug Sand on May 17, 2016 at 5:12 pm

    I’m trying to build an analog meter with a digital text readout. Basically, I need the the source text to read out the rotational value of another layer. As you can see in the image, I want it to be able to read 0 when the needle is at 0, 1 when the needle is at 1 and so on and so forth.

    All help is much appreciated!

    Xavier Gomez replied 10 years, 3 months ago 2 Members · 3 Replies
  • 3 Replies
  • Xavier Gomez

    May 17, 2016 at 5:41 pm

    This might work:

    minRot = -75;
    maxRot = 75;
    minValue = 0;
    maxValue = 6;
    rot = thisComp.layer("Shape Layer 3").transform.zRotation;
    linear(rot, minRot, maxRot, minValue, maxValue);

    Xavier

  • Doug Sand

    May 17, 2016 at 5:46 pm

    Genius, genius, genius! One last question. What can I add to the code to keep the text to only two decimal points?

    -Doug

  • Xavier Gomez

    May 17, 2016 at 6:46 pm

    ***If you want exactly 2 decimals, you can use:

    … // same beginning
    x = linear(rot, minRot, maxRot, minValue, maxValue);
    x.toFixed(2);

    ***And if you want at most 2 decimals:


    x = linear(rot, minRot, maxRot, minValue, maxValue);
    Math.floor(x*100)/100;

    Xavier

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