Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions One Object Smoothly follow another which has Hard movement

  • One Object Smoothly follow another which has Hard movement

    Posted by Mikhail Vasilev on December 30, 2015 at 1:20 pm

    Hi

    I would like to have an expression that allows me to move object “A” Smoothly
    after object “B”

    Object “B” has expression on position property and it moves hard (it jumps from one position to the next position)

    And Object “A” have to move like a trail with 1 sec delay but smoothly without jumping.

    I tried different approaches with “ease” but they all failed.

    OBJECT B EXPRESSION FOR POSITION

    segMin = .2; //minimum segment duration
    segMax = 2; //maximum segment duration
    minVal = [10,-200];
    maxVal =[0,20];

    end = 0;
    j = 0;
    while ( time >= end){
    j += 1;
    seedRandom(j,true);
    start = end;
    end += random(segMin,segMax);
    }
    endVal = random(minVal,maxVal)+value;
    seedRandom(j-1,true);
    dummy=random(); //this is a throw-away value
    startVal = random(minVal,maxVal)+value;
    //ease(time,start,end,startVal,endVal)// delete it -> hard move

    Mikhail Vasilev replied 10 years, 4 months ago 2 Members · 6 Replies
  • 6 Replies
  • Kalleheikki Kannisto

    December 30, 2015 at 2:32 pm

    For follower object’s position something along the lines:

    samples = 10;
    timeframe = .25;
    delay = 1;
    smooth_position = 0;
    for(n = 0; n<samples;n++){
    smooth_position += thisComp.layer("Object").transform.position.valueAtTime(time-delay-timeframe/2+timeframe/samples*n)}
    smooth_position = smooth_position/samples

    That takes (with the current variable settings) 10 samples in the time frame of .25 seconds around the delay point of 1 second to smooth the motion. To smooth further, increase time frame (and samples). A custom smooth function, in essence.

  • Mikhail Vasilev

    December 30, 2015 at 2:58 pm

    Thank you very very much Kalle : )
    It works perfectly.

    But is there any opportunity to add some ease effect to the motion?

  • Kalleheikki Kannisto

    December 30, 2015 at 6:53 pm

    You will get an eased animation if you add a null in between the two objects with the same expression. That is, use the expression to make the null follow the original object and then use the same (with a different target layer) to make the follower follow the null.

    If you then make the settings

    samples = 50
    timeframe = 2
    delay = 1

    in both, you get something so smooth it looks like a rubber band!

    For a bit more in-between, natural look, try:

    samples = 25
    timeframe = 1
    delay = 1

  • Mikhail Vasilev

    December 31, 2015 at 9:30 am

    Big big Thanks again Kalle. It works. That’s exactly what I need.

    But I use this settings for both(Null, and main follower):
    samples =70;
    timeframe = 1;
    delay = .5;

    Thanks again.
    And Happy New 2016 Year !!!

  • Kalleheikki Kannisto

    December 31, 2015 at 9:34 am

    No need to use a samples amount that is higher than your frame rate times timeframe. So if your frame rate is 25 and time frame 1, the highest you need to go is 25 for the samples. Should look exactly the same, but render faster.

    Happy New Year!

  • Mikhail Vasilev

    December 31, 2015 at 5:44 pm

    Thanks, Kalle.
    It optimized my scene a lot because I have many elements with this expression.

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