Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Pause and resume position wiggle while keeping its place

  • Pause and resume position wiggle while keeping its place

    Posted by Noel Powell on June 3, 2020 at 1:24 pm

    Starting and stopping a position wiggle using an if/else statement is not a problem, and has been answered in this forum before (see the code below). But that will make the position jump to its original value when the wiggle stops, instead of pausing its current wiggle value, and then resuming from that value.
    I can imagine doing this in a couple ways that involve either…
    1) Precomposing the layer with the wiggle expression, and then using a Time Remap to pause and resume it
    Or…
    2) Using a slider control with a wiggle expression, and then adding an expression on the Position property that links to the slider control and adds a valueAtTime() function.
    However, I’m really hoping to do this all in one expression. Ideally, the pausing/resuming should be random (for example, wiggling for a maximum of 5 seconds, then stopping for a maximum of 5 seconds). It’d be cool if the position could pause over the course of a few frames, so that it slows down to a stop, and then speeds up as it resumes, but that’s not essential – I would be happy if it just stops dead in its tracks. I appreciate all you expression geniuses (Dan) and your help. Thanks in advance!

    timeToStart = 2;
    timeToStop = 2.5;
    timeToStartOne = 5;
    timeToStopOne = 5.5;

    if ((time > timeToStart) && (time < timeToStop)){
    wiggle(4,300);
    }else if ((time > timeToStartOne) && (time < timeToStopOne)){
    wiggle(4,300);
    }else{
    value;
    }

    Creation Effects – Creative tools for After Effects: https://CreationEffects.com

    Noel Powell replied 6 years, 2 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    June 3, 2020 at 5:45 pm

    Something like this should be close:


    amp = 100;
    freq = 1;
    maxRun = 5;
    minRun = 1;
    maxHold = 5;
    minHold = 1;
    tPrev = t = inPoint;
    seedRandom(index,true);
    accumPrev = accum = curRun = 0;
    while (t <= time){
    curRun = random(minRun,maxRun);
    curHold = random(minHold,maxHold);
    tPrev = t
    accumPrev = accum
    accum += curRun
    t+= curRun + curHold;
    }
    if (time - tPrev < curRun)
    wiggle(freq,amp,1,0.5,accumPrev + time - tPrev)
    else
    wiggle(freq,amp,1,0.5,accumPrev + curRun);

    Dan

  • Noel Powell

    June 3, 2020 at 6:21 pm

    It does exactly as I described – I can’t thank you enough, Dan! There is one unexpected result, though. I failed to mention that I have Auto-Orient along Path turned on. The layer’s orientation is switching back to its default as soon as the layer stops moving. I’ve been trying to tweak it so that instead of completely stopping, it continues at a snail’s pace before it resumes its normal wiggle – just so the auto-orient angle is preserved. But I just don’t understand it well enough to make it work. Would you happen to have a solution?

    Creation Effects – Creative tools for After Effects: https://CreationEffects.com

  • Dan Ebberts

    June 3, 2020 at 6:42 pm

    The only thing I can think of would be to turn off auto orient and use this rotation expression instead:


    v = position.velocity;
    if (length(v) == 0){
    t = time - thisComp.frameDuration;
    while (t > inPoint){
    v = position.velocityAtTime(t);
    if (length(v) != 0) break;
    t -= thisComp.frameDuration;
    }
    }
    radiansToDegrees(Math.atan2(v[1],v[0]))

    Dan

  • Noel Powell

    June 3, 2020 at 6:56 pm

    That’s perfect! Thank you so much for your time, Dan!

    Creation Effects – Creative tools for After Effects: https://CreationEffects.com

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