ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Random movement, then gradual movement to fixed point

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Grant Eisiminger
Random movement, then gradual movement to fixed point
on Jan 23, 2017 at 8:17:05 pm

Hello all, hope I explain this clearly. I'd advise watching the current animation below to make it clear what I'm trying to figure out (sorry for the white boxes).

Right now I have 107 layers that currently exist at a random position, then move from that position to a predetermined fixed point. I accomplished this with the below code (pulled from online, probably Dan Ebbert's) then precomping the layers, time-remapping them, holding on the first frame and animating the camera from there.

The client is largely happy with this, but wants to have the boxes moving at the beginning of animation. So basically, I need them moving randomly for 5:15, then easily moving into their final position. Is there an easy way to accomplish this?







moveTime = 2;
maxX = 700
minX = -700;
maxY = 700
minY = -700;
maxZ = 2000;
minZ = -2000;

seedRandom(index,true);
x = ease(time,inPoint,inPoint+moveTime,random(minY,maxY),0);
y = ease(time,inPoint,inPoint+moveTime,random(minY,maxY),0);
z = ease(time,inPoint,inPoint+moveTime,random(minZ,maxZ),0);
value + [x,y,z]


Return to posts index

Dan Ebberts
Re: Random movement, then gradual movement to fixed point
on Jan 23, 2017 at 9:49:07 pm

Something like this maybe:


tMax = 5.5;
minDur = 1.5;
maxDur = 2.5;
vMin = [-700,-700,-2000];
vMax = [700,700,2000];
seedRandom(index,true);
tNext = tPrev = -random(minDur);
done = false;
while (tNext <= time){
tPrev = tNext;
if (tPrev > tMax){
done = true;
break;
}
tNext += random(minDur,maxDur);
}
if (done){
v = [0,0];
}else{
seedRandom(tPrev,true);
vPrev = random(vMin,vMax);
if (tNext > tMax){
vNext = [0,0];
}else{
seedRandom(tNext,true);
vNext = random(vMin,vMax);
}
v = ease(time,tPrev,tNext,vPrev,vNext);
}
value + v;



Dan



Return to posts index

Grant Eisiminger
Re: Random movement, then gradual movement to fixed point
on Jan 23, 2017 at 10:36:14 pm

Ooh, that gets me very close. I've been messing with some of the variables, but one problem I'm running into right now is that the cells aren't landing at the same uniform time. I actually have them set to land in different "waves" as the client wants them to organize from the center cell outward. I adjusted the minDur/maxDur variables of your code for each wave, which helps with the timing, but it looks like the cells move at the same overall pace to their final resting point, which messes with the "wave" effect a bit.

Still, this gets me much closer than I was before. I'll continue batting away at this. Thanks so much!


Return to posts index


Dan Ebberts
Re: Random movement, then gradual movement to fixed point
on Jan 24, 2017 at 12:05:25 am

Hmmmm... Ok, try this one:


tMax = 5.5;
minDur = 1.5;
maxDur = 2.5;
vMin = [-700,-700,-2000];
vMax = [700,700,2000];
if (time > tMax){
v = [0,0];
}else{
seedRandom(index,true);
tNext = tPrev = tMax;
while (tNext >= time){
tPrev = tNext;
tNext -= random(minDur,maxDur);
}
if (tPrev == tMax){
vPrev = [0,0];
}else{
seedRandom(tPrev,true);
vPrev = random(vMin,vMax);
}
seedRandom(tNext,true);
vNext = random(vMin,vMax);
v = ease(time,tNext,tPrev,vNext,vPrev);
}
value + v;



Dan



Return to posts index

Grant Eisiminger
Re: Random movement, then gradual movement to fixed point
on Jan 24, 2017 at 3:47:25 pm

That's perfect! I actually think I may have figured out a way with the earlier code (adjusting the tNext value) but this way looks like it may be more efficient.

I left a tip in your jar, thank you, this helps so much!


Return to posts index

Dan Ebberts
Re: Random movement, then gradual movement to fixed point
on Jan 24, 2017 at 6:12:51 pm

Thanks -- I appreciate it!

Dan



Return to posts index

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