Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Movement control for counter

  • Movement control for counter

    Posted by Pierre Guiet on April 26, 2007 at 6:28 pm

    Hi guys,

    I’m having trouble getting something to work.
    Here’s the problem.

    I have a counter that is hooked to the rotation value of a clock needle. The digit counter is just a graphic that has numbers 0 – 9 running up and down. As the clock needle moves this changes the counter’s y position to reflect the position of the needle. So far so good.
    Now I would like to add a twist. I don’t want the counter graphic to move until the needle hits exactly one or two 3 4 etc. So it would immediately move to the correct number once it got to the correct place on the clock.

    Dan helped me out before … Thanks for that here’s the code I’m using

    yPosition = thisComp.layer(“NEEDLE”).transform.rotation/0.72%5000*.1;
    [value[0], yPosition-81]

    Dan Ebberts replied 19 years, 3 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    April 27, 2007 at 1:15 am

    It’s hard to say exactly without knowing what the ranges are (what’s the 5000, for example?), but it’s likely going to involve the use of Math.floor() to hold the value at some level until the next threshold is crossed.

    Dan

  • Pierre Guiet

    April 27, 2007 at 5:24 pm

    This works for the first rotation. The number increments in one frame. What I would like to do is reset
    yPosition in the else statement to the value it started with in the script. Is there a way to do this?
    Seems as though every frame the code is executed from the start of the script. Just not sure how to do this?

    //Use the needle to position the numbers
    // to get the .72 I divided 36 degrees the amount it takes to get to 1 by 50 pixels the height of the number box
    //from dan yPosition = thisComp.layer(“NEEDLE”).transform.rotation/0.72%360;
    // from dan [value[0], yPosition-105]
    //I believe 500 is the height of the graphic from the bottom to bottom of zero check scrnum4.ai file
    //mutitply by .1 to slow it down for the thousands had to add a zero to 500 so it wouldn’t flip over
    //% is the JavaScript modulus operator. x%y returns the remainder that results from dividing x by y. Very useful for translating a continuously growing value into a cyclic one FROM DAN creative cow
    // good one yPosition = thisComp.layer(“NEEDLE”).transform.rotation/0.72%5000*.1;
    yPosition=thisComp.layer(“NEEDLE”).transform.rotation/0.72%5000/500;
    yTempPosition=Math.floor((thisComp.layer(“NEEDLE”).transform.rotation/0.72%5000/500));

    if (yPosition < 1){ ( yTempPosition ) }else{ yTempPosition=yTempPosition + 50; // reset yPosition back to its original value here // not sure how to set up this kind of value } // [value[0], yPosition-81]; [value[0], yTempPosition-81];

  • Dan Ebberts

    April 27, 2007 at 8:32 pm

    If you just need the value to always be between 0 and -50 as yTemp goes beyond -50, this should do it:

    yTemp%50

    Dan

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