Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Wiggle only negative values

  • Wiggle only negative values

  • Navarro Parker

    June 15, 2015 at 5:27 pm

    I have a shape layer that I have drawn at it’s maximum length. I want to wiggle the scale in Y only — but only subtract wiggle values so it never exceeds the maximum length.

    Tried modifying a pervious expression, but got an error:
    myWiggle = wiggle(2,75);
    delta = Math.abs( myWiggle - value[1] );
    [value[0],value - delta[1]]

  • Dan Ebberts

    June 15, 2015 at 5:52 pm

    Try this:

    myWiggle = Math.abs(wiggle(2,75)[1]-value[1]);
    value – [0,myWiggle]


  • Navarro Parker

    June 15, 2015 at 6:18 pm

    Brilliant at always! Thanks Dan!!

  • Navarro Parker

    June 15, 2015 at 6:25 pm

    Ooops… maybe have spoken too soon.

    I’m getting negative values if I use a wiggle amplitude of 100 (for 100% scale). The minimum it should ever go to is 0% scale with Math.abs, right? The starting scale values are 100,100.

  • Dan Ebberts

    June 15, 2015 at 6:42 pm

    wiggle() can sometimes go over the amplitude amount. Try it this way:

    myWiggle = clamp(Math.abs(wiggle(2,75)[1]-value[1]),0,100);
    value – [0,myWiggle]


  • Navarro Parker

    January 21, 2016 at 3:20 am

    Hi Dan!

    I’ve revisited this expression today. And I’ve noticed a funky situation. I’m using a low freq (.25) and I get this weird “bounce” when the wiggle reaches the maximum value. It doesn’t gracefully flow from a low value to a high value to a low value.

    It reaches the maximum and then immediately bounces backward like it hits a wall. I’d describe it as “triangle” interpolation.

    I’m using an octave of 1 in hopes to get the most flowy, gentle wiggle.

    Any ideas how to smooth this expression out so there’s more of a gentle sine-y interpolation between min and max values?

  • Navarro Parker

    January 21, 2016 at 3:40 am

    Here’s a screenshot of the value graph that shows the bouncy quality

  • Dan Ebberts

    January 21, 2016 at 5:18 am

    I don’t know of a really good way to do what you’re trying to do, due to the unpredictability of wiggle’s peak values. I’ve seen peak values 33% higher than the specified value. You can use Math.abs to fold the wave back on itself, but as you’ve seen, that creates sharp corners. You could clamp it, but that creates flat spots. You could connect the amplitude and an offset to sliders so you can adjust your specific waveform to fit perfectly within your limits. You can automate the whole thing with a script. Or, if your comp isn’t too long you can use an expression that first finds the min and max values of the entire wave (from inPoint to outPoint) and use those values to fit the waveform within your desired range. If it bogs down (because at each frame it has to examine all frames), you could convert the expression to keyframes. Play around with this opacity expression:

    targetMin = 20;
    targetMax = 100;

    t = inPoint;
    min = 1.5;
    max = -1.5;
    while (t < outPoint){
    w = rotation.wiggle(.25,1,1,.5,t)-rotation.valueAtTime(t);
    min = Math.min(w,min);
    max = Math.max(w,max);
    t += thisComp.frameDuration;
    w = rotation.wiggle(.25,1) - rotation;


  • Navarro Parker

    January 21, 2016 at 8:24 pm

    You’re right, it isn’t a speed demon (on ten layers in a 1000 frame comp)!

    But it works great! Compare the difference in value graphs. Completely eliminates the bouncy wiggle!

Viewing 1 - 9 of 9 posts

Log in to reply.

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