Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Number Counter with expression slider not pass zero

  • Random Number Counter with expression slider not pass zero

    Posted by Bert Beltran on October 28, 2013 at 6:32 pm

    I have an text layer were the source text is parent to a expression slider. The expression looks like this:
    Math.round(effect(“Slider Control”)(“Slider”)). Then I added a wiggle expression to the slider control, but my issues is that the wiggle expression sometimes runs into negative numbers and I want to set the minimum value to Zero.

    I tried this expression that came close to doing what I wanted it to do but there are times it will jump to a negative number.

    Math.min=0;
    wiggle(1,50)

    Last thing how would I create an expression so that it has a max limit number as well. So that it did not pass the number 100. So it would count random numbers from 0 to 99.

    Muchos Thank You’s

    Kevin Camp replied 12 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Kevin Camp

    October 28, 2013 at 6:44 pm

    Math.min() and Math.max() need two values (unless they assume zero as one value if only one value is present).

    so for your first expression you’d want something like this:

    w = wiggle(1,50);
    Math.max(0,w)

    you’d use Math.max() since you want it to return zero if w is less than zero.

    to values to a range (0-99), you’d use both Math.min() and Math.max(), and you can embed one inside the other:

    w = wiggle(1,50);
    Math.max(0,Math.min(99,w))

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Kevin Camp

    October 31, 2013 at 9:33 pm

    clamp() would also work here…

    w = wiggle(1,50);
    clamp(w,0,99)

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

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