Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Progressive, smooth wiggle frequency change…

  • Progressive, smooth wiggle frequency change…

  • Nico Jones

    June 8, 2010 at 4:13 pm

    ‘m trying to mimmick a POV shot, purely in AE. I’ve got a 3D cockpit set up in Invigorator, and a camera that is going to be my character’s ‘eyes’.

    It’s all working fine, but I need to add wiggle to the camera POV (or position) to give realistic movement. I have a null object set up with 2 sliders controlling the amount and frequency of the wiggle on the camera, all working nicely.

    The problem comes when I try to animate the sliders. Keyframing the severity of the wiggle is fine, but when I animate the frequency I get a massive, out of control judder between keyframes.

    I really need to be able to smoothly change between different levels of wiggle frequency. Any ideas how I might be able to do this?

    Here is a project file that illustrates the problem. Notice the judder inbetween the keyframes. It’s not the boomerang effect, easing the keyframes doesn’t help and I can’t use hold keyframes without losing the transition between frequency changes.

    https://www.yousendit.com/download/YWhOSlI5OW5TSUR2Wmc9PQ

    Many thanks,

    nico

  • Dan Ebberts

    June 8, 2010 at 7:29 pm

    Changing a wiggle’s frequency smoothly is surprisingly complicated. You can’t just animate the frequency parameter because as the frequency value changes, the expression is evaluated as if it had been using the new frequency the entire time. So weird things happen. If you’re animating using linear keyframes, you’ll have better luck animating wiggle’s seldom-used 5th parameter (time). Here’s an example that integrates (converts frequency to time elapsed) your frequency control and uses that value to advance through time of a wiggle with a nominal 1 Hz frequency:

    freq = thisComp.layer("Wiggle Control Sliders").effect("FREQUENCY")("Slider");
    amp = thisComp.layer("Wiggle Control Sliders").effect("AMOUNT")("Slider");

    if (freq.numKeys > 0){
    accum = 0;
    v0 = freq.valueAtTime(0);
    t0 = 0;
    i = 1;
    while (i <= freq.numKeys){ t = freq.key(i).time; if (t < time){ accum += (v0 + freq.key(i).value)*(t - t0)/2; v0 = freq.key(i).value; t0 = t; if (i == freq.numKeys){ accum += (time - t0)*v0; } }else{ accum += (time - t0)*v0; break; } i++; } }else{ accum = freq*time; } wiggle(1,amp,1,.5,accum);

    Dan

  • Dan Ebberts

    June 8, 2010 at 7:37 pm

    Hang on, that doesn’t work quite right….

    Dan

  • Dan Ebberts

    June 8, 2010 at 7:53 pm

    OK – sorry for the misfire. I think this works:


    freq = thisComp.layer("Wiggle Control Sliders").effect("FREQUENCY")("Slider");
    amp = thisComp.layer("Wiggle Control Sliders").effect("AMOUNT")("Slider");

    if (freq.numKeys > 0){
    accum = 0;
    v0 = freq.valueAtTime(0);
    t0 = 0;
    i = 1;
    while (i <= freq.numKeys){ t = freq.key(i).time; if (t < time){ accum += (v0 + freq.key(i).value)*(t - t0)/2; v0 = freq.key(i).value; t0 = t; if (i == freq.numKeys){ accum += (time - t0)*v0; } }else{ accum += (freq + v0)*(time - t0)/2; break; } i++; } }else{ accum = freq*time; } wiggle(1,amp,1,.5,accum);

    Dan

  • Nico Jones

    June 9, 2010 at 1:07 pm

    Many thanks for the help, Dan. I can’t seem to get smooth results when applying that expression to my project though – it gives a jagged hit just at as the second keyframe happens. I’ll admit that this expressionis a bit beyond me, so I can’t really make any tweaks myself…

    Nico J BB

  • Dan Ebberts

    June 9, 2010 at 3:09 pm

    I just tried it again with your project and I’m not seeing that behavior (it seems very smooth at the 2nd keyframe). That was the problem with the first version I posted though. Are you sure you didn’t use that one? The only difference is the 9th line from the end, which should be:

    accum += (freq + v0)*(time – t0)/2;

    Dan

  • Nico Jones

    June 9, 2010 at 3:21 pm

    How strange…yes I’m using the right one.

    The actual transition is smooth, but it’s jumping a few pixels on the frame after the second keyframe. Even though the value is the same…

    https://webfilemanager.co.uk/dsf.php?fileid=B1LuN3kz

    Maybe something in my setup is awry…

    Nico J BB

  • Matthew Roberts

    May 19, 2016 at 4:15 am

    Hi Dan – this looks great.

    Is there a way to do this smooth wiggle only on one axis (e.g. on Y only?)

    Matthew Roberts
    https://kupon.co.uk/
    https://dribbble.com/matthewkupon

  • Dan Ebberts

    May 19, 2016 at 5:38 am

    Maybe just change the last line to this:

    w = wiggle(1,amp,1,.5,accum);
    [value[0],w[1]]

    Dan

  • Paul Wright

    May 22, 2017 at 8:51 am

    Dan, you are the man. Thanks very much for this script. Its helped me out immeasurably. Only found it yesterday.

    Ta 🙂

Viewing 1 - 10 of 12 posts

Log in to reply.

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