Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Start wiggle at timepoint X without jumping

  • Start wiggle at timepoint X without jumping

    Posted by Jay Schweg on November 15, 2016 at 10:41 am

    Hi there

    I want to start a wiggle animation at a specific timepoint for a layer’s position.

    I am currently using this code


    maxFreq = 3;
    freq = 0;

    if (time < 2.8) {
    freq = 0; // 0 wiggles per second
    } else {
    if (freq < maxFreq) {
    freq = freq + 0.05; // wiggles per second
    }
    }

    amp = 25; // px units applied for wiggle
    loopTime = 10;
    t = time % loopTime; // % returns remainder - resets every looptime to 0
    wiggle1 = wiggle(freq, amp, 1, 0.5, t);
    wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
    w = linear(t, 0, loopTime, wiggle1, wiggle2);
    [w[0], w[1]]

    This code will start my wiggeling after 2.8s. But unfortunately I can see the position jumping in the beginning. I thought I could improve it by slowly increasing the freq variable, but obviously it would not work. Any idea how I could get this to work?

    Thanks

    Jay Schweg replied 9 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    November 15, 2016 at 5:06 pm

    Did you try ramping the amp variable from 0 to 25 instead?

    Dan

  • Jay Schweg

    November 15, 2016 at 5:14 pm

    I did actually. That was the first thing I did after the post. I got kind of a working example, but as I was not sure about if my code actually works (no debugging or logging option, except from a text layer output, which I didn’t want to to ;)) I stopped playing around.
    So you would say this works, by increasing the amp value?

    I also experienced problems with the following: I assume that the expression code is called everyframe. So how I can I increment a variable during my animation?
    So
    freq = freq + 0.05; Does not work at all.
    I thought maybe by not declaring it at the beginning, but this would make my expression fail.

    Is my assumption correct?

    My only other idea was to link the freq – or the amp – to time.
    So I would set something like this:
    amp = time * 0.05

    So after the first frame I would have time = 1 and amp = 0.05, right?
    And after the second time = 2, amp = 0.1.
    I hope I understand the time variable correctly…

    Any hints related to these things are welcome :).
    Thanks in advance.

    Cheers

  • Dan Ebberts

    November 15, 2016 at 5:30 pm

    You are correct that variables do not survive from frame to frame. You could do something like this to ramp amp from 0 to 25 over half a second:

    tStart = 2.8;
    amp = linear(time, tStart, tStart+.5, 0, 25);

    Dan

  • Jay Schweg

    November 15, 2016 at 5:32 pm

    Oh that’s a nice idea. I think I need to internalize some of those AE expression concepts a little bit.
    Thanks mate, for the hint. I’ll try it out.

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