Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Replace a comma with a dot in wiggle expression

  • Replace a comma with a dot in wiggle expression

    Posted by Yonner Draas on October 12, 2016 at 5:56 pm

    I want to gradually have more camera shake in my 3d camera. After a bit of searching, I found out I had to make two slider expressions on a null object, and use the pick whip to connect those with my camera. Then I could keyframe my amplitude and frequency. Now my expression for my Camera Orientation is:
    wiggle(thisComp.layer(“Null 1”).effect(“frequency”)(“Slider”),thisComp.layer(“Null 1”).effect(“amplitude”)(“Slider”))
    Problem is, in the period between keyframes my camera starts shaking like crazy. I suspect this has something to do with me living in a country that uses commas instead of dots. So the value of my slider is a number with commas. Problem is, numbers inside expressions are still with dots instead of commas, which basically causes the wiggle on a random moment between two whole numbers to be (for example):
    wiggle(1,4,5,2)
    This makes the camera shake more than I want it to. Is there any way to “convert” this to:
    wiggle(1.4,5.2)
    I’d much appreciate a solution!

    Sander

    wiggle(thisComp.layer("Null 1").effect("frequency")("Slider"),thisComp.layer("Null 1").effect("amplitude")("Slider"))

    Yonner Draas replied 9 years, 10 months ago 2 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    October 12, 2016 at 6:41 pm

    If you’re keyframing wiggle frequency, you probably need to take a look at this:

    https://motionscript.com/articles/speed-control.html#wiggle

    Dan

  • Yonner Draas

    October 12, 2016 at 7:35 pm

    Thank you for the response.
    I tried applying the expression to the Orientation but simply got an error: “Function effect is undefined.”
    Since it’s such a complex expression I’m having a hard time finding my mistake. I also don’t really know how I would customize it.
    What did I do wrong?

    freq = effect("Slider Control")("Slider");
    amp = 10;
    n = freq.numKeys;
    if (n > 0 && freq.key(1).time < time){
    accum = freq.key(1).value*(freq.key(1).time - inPoint);
    for (i = 2; i <= n; i++){
    if (freq.key(i).time > time) break;
    k1 = freq.key(i-1);
    k2 = freq.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
    }
    accum += (freq.value + freq.key(i-1).value)*(time - freq.key(i-1).time)/2;
    }else{
    accum = freq.value*(time - inPoint);
    }
    wiggle(1,amp,1,.5,accum)

  • Dan Ebberts

    October 12, 2016 at 7:46 pm

    I’m assuming your layer has a Slider Control named “Slider Control”, is that correct? If so, I’m not sure what’s going on–I just tried it on Orientation and it works for me.

    Dan

  • Yonner Draas

    October 12, 2016 at 8:05 pm

    Well its my camera I want to wiggle, and I can’t apply effects to a camera, so my slider is on the null object. I don’t really know what in the expression I need to replace with what, since I’m quite a rookie at expressions. My expression actually looks like this (and I get the error here):

    freq = effect(thisComp.layer("Null 1").effect("Slider Control")("Slider"));
    amp = 10;
    n = freq.numKeys;
    if (n > 0 && freq.key(1).time < time){
    accum = freq.key(1).value*(freq.key(1).time - inPoint);
    for (i = 2; i <= n; i++){
    if (freq.key(i).time > time) break;
    k1 = freq.key(i-1);
    k2 = freq.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
    }
    accum += (freq.value + freq.key(i-1).value)*(time - freq.key(i-1).time)/2;
    }else{
    accum = freq.value*(time - inPoint);
    }
    wiggle(1,amp,1,.5,accum)

  • Dan Ebberts

    October 12, 2016 at 8:11 pm

    Try changing the first line to this:

    freq = thisComp.layer(“Null 1”).effect(“Slider Control”)(“Slider”);

    Dan

  • Yonner Draas

    October 12, 2016 at 8:22 pm

    Thank you, that worked, but now I get an error at line 4: ” warning: Expected: ) ”
    By the way, thanks for taking the time to help me with this!

  • Dan Ebberts

    October 12, 2016 at 8:32 pm

    I think your less-than symbols may have gotten munched the the forum’s HTML (it happens if you preview before you post code). Try a fresh version:


    freq = thisComp.layer("Null 1").effect("Slider Control")("Slider");
    amp = 10;
    n = freq.numKeys;
    if (n > 0 && freq.key(1).time < time){
    accum = freq.key(1).value*(freq.key(1).time - inPoint);
    for (i = 2; i <= n; i++){
    if (freq.key(i).time > time) break;
    k1 = freq.key(i-1);
    k2 = freq.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
    }
    accum += (freq.value + freq.key(i-1).value)*(time - freq.key(i-1).time)/2;
    }else{
    accum = freq.value*(time - inPoint);
    }
    wiggle(1,amp,1,.5,accum)

    Dan

  • Yonner Draas

    October 12, 2016 at 8:41 pm

    It worked! Thank you so much, it looks perfect now.

    Sander

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