Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions randomized motion path with given start and end position

  • randomized motion path with given start and end position

    Posted by Patrick Grossien on August 10, 2015 at 6:53 pm

    Alright, it’s been a frustrating day and I’m not getting anywhere at the moment. So I’m putting this third thread out here in the hope that someone smarter than me can get me started or let me know how to do this.

    I have a slim vertical composition – similar to a vertically held smartphone.

    I’m trying to create a randomised move with an element starting out of view below the bottom of the comp moving in a randomised slight arc out of view at the top of the frame and then start again out of view at the bottom of the comp moving back up with a slightly different arc. I also want to be able to control the duration/speed of the movement (overall) just as Dan does with the Min and Max segment duration values.

    The movement should look a little bit like a bubble rising in a glass with slow and easy left to right motion.

    I tried to wrap my head around Dan’s Random Motion scripts. Maybe I’m just too tired to think straight, but I’m unable to adapt that knowledge to what I need. The frustrating part is that I believe it’s probably relatively straight forward.

    Any help with this or pointing me into the right direction how I could get this to work is hugely appreciated.

    Thanks a ton, everybody!

    David Cabestany replied 10 years ago 4 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    August 10, 2015 at 8:07 pm

    This probably isn’t exactly what you have in mind, but it might get you started. It’s designed for a bubble field, where you create one bubble and then duplicate the layer a bunch of times. Each time trough, a layer gets a different path. It’s set up to start with each layer already on screen, but if you don’t want that, just set prerun to zero.

    minWobble = 10;
    maxWobble = 25;
    minLife = 2;
    maxLife = 3;
    minFreq = .5;
    maxFreq =1;

    seedRandom(index,true);
    life = random(minLife,maxLife);
    prerun = random(maxLife);

    t = (time-inPoint+prerun)%life;
    seedRandom(Math.floor((time-inPoint+prerun)/life),true);
    wobble = random(minWobble,maxWobble);
    freq = random(minFreq,maxFreq);
    phase = random(Math.PI*2);
    xBase = random(wobble + width/2,thisComp.width-wobble-width/2);
    x = xBase + wobble*Math.sin(t*freq*Math.PI*2 + phase);
    y = linear(t,0,life,thisComp.height+height/2,-height/2);
    [x,y]

    Dan

  • Patrick Grossien

    August 10, 2015 at 8:37 pm

    You’re the best! Thanks a ton. This looks like I might get it to work the way I want. I’ll take some time to test it out and will report back.

    You’re amazing! Thank you 🙂

  • Patrick Grossien

    August 11, 2015 at 9:14 pm

    Thanks again Dan, I dropped a little thank you tip in your jar! 🙂

    I got this to work the way I wanted it to. Even though I had a little bit of trouble getting the frequency correct, because I wanted a max amount of 2 curves per path and therefore it needed to be linked to the life span / speed of the bubbles.

    Through trial and error I got that timing to work with the following, doing the same thing for the min and max values.

    (minLife is at 30 at the moment)
    minFreq = (minLife/720)

    I was trying something along the lines of
    minFreq = (minLife/(minLife*60));

    which didn’t work exactly how I want it

    Maybe you can unravel for me how frequency in connection to time could be calculated, so that a variable can be set to the amount of peaks the bubble is doing per path and not the amount per sec as freq. is doing it now.

    Best,
    Patrick

  • Patrick Grossien

    August 11, 2015 at 9:32 pm


    minLife = 30
    peak = 6
    minFreq = minLife/(minLife*(24/peak));

    this seems to be working somewhat – but why 24? 😀
    and what would be truly accurate?

    I’ll then create a maxPeak and minPeak to add to the code for easier control.

  • Dan Ebberts

    August 11, 2015 at 10:26 pm

    If you want to tie the frequency to the life, I’d do something like this:

    minWobble = 25;
    maxWobble = 50;
    minLife = 10;
    maxLife = 15;

    seedRandom(index,true);
    life = random(minLife,maxLife);
    minPeriod = life/2;
    maxPeriod = life/1.5;
    period = random(minPeriod,maxPeriod);
    freq = 1/period;
    prerun = random(maxLife);

    t = (time-inPoint+prerun)%life;
    seedRandom(Math.floor((time-inPoint+prerun)/life),true);
    wobble = random(minWobble,maxWobble);
    d = thisComp.height + height;
    phase = random(Math.PI*2);
    xBase = random(wobble + width/2,thisComp.width-wobble-width/2);
    x = xBase + wobble*Math.sin(t*freq*Math.PI*2 + phase);
    y = linear(t,0,life,thisComp.height+height/2,-height/2);
    [x,y]

    Dan

  • Patrick Grossien

    August 12, 2015 at 9:18 am

    Thank you, Dan.

    Is there a reason, that “d” isn’t used after being defined?

  • Dan Ebberts

    August 12, 2015 at 11:31 am

    No, I started down one path, but ended up going a different way.

    Dan

  • Joey Harvey

    April 18, 2016 at 10:44 pm

    I’m writing here as the subject title is exactly what I think I’m looking for but I don’t think the solution is quite suitable for my needs
    (unless I’m misinterpreting how to adapt it).

    I have a shape layer that has an exact start position. I want the shape to move around my composition in a classic motionscript.com ‘random motion – more chaotic’ manner then at a given time proceed to an exact end position.

    I have managed to get a layer to start and stop moving when I want it to, but not been able to wrangle the layer to the correct start and stop positions.

    Could anyone help put me on the right path?

  • David Cabestany

    April 24, 2016 at 4:34 pm

    Maybe I’m oversimplifying things or just didn’t understand what you need but, can’t you achieve this by adding a wiggle expression to your object and then parent it to a null with the arc animation?

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