Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Revert value to zero once to comp edge

  • Revert value to zero once to comp edge

    Posted by Jim Johnston on March 18, 2018 at 5:33 am

    Hey all. I have a position expression which moves in a certain direction each frame as follows (thanks to Dan Ebberts).

    spd = effect("Slider Control")("Slider");
    angle = effect("Angle Control")("Angle");
    d = spd*(time-inPoint);
    r = degreesToRadians(angle);
    x = d*Math.cos(r);
    y = d*Math.sin(r);
    value + [x,y]

    But I need the x and y values to reset to 0 once they reach a certain threshold (such as the comp width/height).

    I tried adding if(x>100) x=0;
    which works but keeps the value of x at 0 for the remainder..

    Something really simple I suspect but not getting anywhere at the moment!

    Jim Johnston replied 8 years, 2 months ago 1 Member · 1 Reply
  • 1 Reply
  • Jim Johnston

    March 18, 2018 at 6:11 am

    Figured it out. AE doesnt store variables over time apparently. So a modulus function works instead just fine I think

    spd = effect("Slider Control")("Slider");
    angle = effect("Angle Control")("Angle");
    d = spd*(time-inPoint);
    r = degreesToRadians(angle);
    x = d*Math.cos(r);
    y = d*Math.sin(r);
    value + [x%1280,y%720]

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