FORUMS: list search recent posts

Maximum trail length?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Darryl Torke
Maximum trail length?
on Aug 27, 2012 at 9:34:42 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)


Return to posts index

Dan Ebberts
Re: Maximum trail length?
on Aug 28, 2012 at 1:54:12 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



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]