Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Maximum trail length?

  • Maximum trail length?

    Posted by Darryl Torke on August 27, 2012 at 9:34 pm

    Hello,

    I am trying to make an object trail another object (a “follower” and a “leader”). However, I would like the “follower” object to never go beyond a certain pixel range (50 pixels lets say), no matter how fast the “leader” is moving. So essentially an ‘upper limit’ to a trail length…

    I wish I could give some sample code, but I simply don’t know where to begin after copying the ‘creating trails’ code (ebberts).

    delay = 5; //number of frames to delay
    d = delay*thisComp.frameDuration*(index - 1);
    thisComp.layer(1).position.valueAtTime(time - d)

    Dan Ebberts replied 13 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    August 28, 2012 at 1:54 am

    I don’t know of an easy way to do that. I think you’d need to loop back in time to find out how long ago the leader was 50 pixels from where it is now and use that as a delay limit. Something like this maybe:


    p = thisComp.layer("leader").transform.position;
    delay = 5;
    maxD = 50;p
    t = time - thisComp.frameDuration;
    useMax = false;
    while (t >= inPoint){
    d = length(p.value,p.valueAtTime(t));
    if (d >= maxD){
    t += thisComp.frameDuration;
    useMax = true;
    break;
    }
    t -= thisComp.frameDuration;
    }
    p.valueAtTime(useMax ? t : time - delay)

    Dan

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