Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random motion gradually going back to the original location

  • Random motion gradually going back to the original location

    Posted by Yoshiko Tanaka on January 2, 2016 at 4:27 pm

    Hello!

    I have been using AE for quite some time and I am finally starting to use expressions.

    I have a group of objects on the stage and I want to move them around randomly( (like a bunch of ants moving around), then they start moving around smaller area and eventually going back to the original location. I thought of using wiggle and simply control the values in keyframes but the problem is that wiggling is like flashing element in which each object jumps from one point to the other instead of actually “moving”.

    So, I found this code which allows me to create random motion. But the problem is that I don’t know how I can gradually decrease/limit the movement to go back to the original location. Here is what I have so far.

    If you have tips of how I can modify this code I would really appreciate it. Thank you!

    Yoshiko

    tMin = .25; //minimum segment duration
    tMax = 1.5; //maximum segment duration
    minVal = [0.1*thisComp.width, 0.1*thisComp.height];
    maxVal = [0.6*thisComp.width, 0.6*thisComp.height];
    end = 0;
    j = 0;
    while (time >= end){
    j ++;
    seedRandom(j,true);
    start = end;
    end += random(tMin,tMax);
    }
    endVal = random(minVal,maxVal);
    seedRandom(j-1,true);
    dummy = random(); //this is a throw-away value
    startVal = random(minVal,maxVal);
    ease(time,start,end,startVal,endVal)

    Yoshiko Tanaka replied 10 years, 3 months ago 2 Members · 4 Replies
  • 4 Replies
  • Kalleheikki Kannisto

    January 2, 2016 at 4:56 pm

    [Yoshiko Tanaka] “wiggling is like flashing element in which each object jumps from one point to the other instead of actually “moving””

    That depends on the settings. Wiggling is quite smooth if the first attribute (wiggles per second) is low. Try wiggle(.5, 500) for instance. You can do what you describe by creating a slider control and connecting the second value to it and animating the slider.

    If you add a slider control on a separate layer called “control”, the code would be:

    wiggle (.5, thisComp.layer(“Control”).effect(“Slider Control”)(“Slider”))

    And that single slider would control the amount by which all the layers with that expression wiggle from their original position. You can then animate the slider from your given amount to zero.

  • Yoshiko Tanaka

    January 2, 2016 at 5:18 pm

    Thank you for your response. I am sorry if this sounds too silly… I am still learning coding in AE and I am very newbie… How do you add a slider control to a separate layer? You mean like null object?

  • Kalleheikki Kannisto

    January 3, 2016 at 4:15 pm

    It can be a null object, although most people (like myself) prefer solids, as they are easier to select on-screen. You can hide the solid before rendering, the expression will work just fine. The Slider Control can be found under Effects & Presets > Expression Controls.

  • Yoshiko Tanaka

    January 6, 2016 at 2:19 pm

    Thank you for your suggestion! I used a slider with null and it worked as I wanted. Below is the link. Much appreciated!

    wiggle(0.8,thisComp.layer("Null 3").effect("numbers")("Slider"))

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