Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Initial Scale plus wiggle scale

  • Random Initial Scale plus wiggle scale

    Posted by Pete Burges on January 9, 2026 at 12:04 am

    Apologies if this has been covered elsewhere, I searched the threads but couldn’t find a good match.

    I’ve made a setup to randomise the scale of a layer and also apply an animatable wiggle to it. I’ve linked it to sliders which control frequency, amount, amount multiplier and random seed. It works…but not as intended.
    You’ll see in the script below that the intention was to have a random start scale clamped between 25 and 100%, and then apply wiggle to it.

    s= comp(“AutoSparkle”).layer(“Control”).effect(“SEED”)(“Slider”);
    seedRandom(index*s, true);
    r= random(25,100);
    f= comp(“AutoSparkle”).layer(“Control”).effect(“FREQ”)(“Slider”);
    m= comp(“AutoSparkle”).layer(“Control”).effect(“AMOUNT MULTIPLIER”)(“Slider”);
    a= comp(“AutoSparkle”).layer(“Control”).effect(“AMOUNT”)(“Slider”)*m;
    clamp (a,5,300);
    w= wiggle(f,a);
    [r+w[0],r+w[0]]

    So I would expect that with the Amount slider at 0, the layer size would
    be between 25 or 100. But somehow I am getting initial scales over 100%
    and I am not sure why. I think it’s something to do with the scale array because [r,r] works for the initial random scale on it’s own, but the wiggle needs to be [w[0],w[0]] I don’t understand it well enough to figure it out though. I’d be grateful if anyone can tell me where
    I’ve gone wrong.

    Thanks!

    Pete Burges replied 4 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    January 9, 2026 at 12:42 am

    I haven’t tested this, but you might just need to separate the wiggle from the original value by changing this:

    w= wiggle(f,a);

    to this:

    w= wiggle(f,a) - value;
  • Pete Burges

    January 9, 2026 at 1:42 am

    Mr Ebberts, you are a legend. That seemed to do the trick- thanks!
    I was thinking that after the first few lines the value was changed to the result of r, but your solution suggests that the pre-expression value persists until the end. A lot of my (very amateur) scripting attempts work under this incorrect assumption, so would you mind explaining a little about it…?
    Thanks,
    Pete

  • Dan Ebberts

    January 9, 2026 at 4:27 am

    In most cases, the result of the expression replaces the static/keyframed value of the property, but wiggle() is a special case. The pre-expression value is included in the result, with the wiggle amount (+ or -) being added to it. So if you’re just interested in the wiggle part, you need to subtract value to isolate the wiggle.

  • Pete Burges

    January 14, 2026 at 12:13 am

    Aha, that explains a lot. Thanks Dan, much appreciated!

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