ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Move layer from fixed position to random position, within range

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kyle Hamrick
Move layer from fixed position to random position, within range
on May 26, 2010 at 4:03:29 am

Hey all,

Got an expression problem I can't quite wrap my head around.

I've got an animation where groups of people icons are multiplying exponentially. It's getting complex very quickly, and I'd love to help automate my workflow a little and let the expressions do the heavy lifting. I'm close, but haven't quite gotten it working. Figured I'd see if anyone else might be able to take a stab at this.

The layers in question spawn at [0,35,0], then need to move, over 30 frames beginning at the layer's in point, to [random (-30,30), 35, random (-20,-80)], where it will stay for the rest of the comp.

I've gotten results somewhat close to what I need by adapting parts of this original expression from Motionscript:

segMin = .3; //minimum segment duration
segMax = .7; //maximum segment duration
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];

seedRandom(index,true);
segDur = random(segMin, segMax);
seed = Math.floor(time/segDur);
segStart = seed*segDur;
seedRandom(seed,true);
startVal = random(minVal,maxVal);
seedRandom(seed+1,true);
endVal = random(minVal,maxVal);
ease(time,segStart,segStart + segDur, startVal, endVal);

...But that's designed to repeat. Expressions dealing with time have always somewhat tripped me up, and I can't seem to figure out what I'm missing.

I'd love to be able to tie each random min/max value to a respective master slider, allowing me to easily control the density of this crowd. I can't imagine a way to build an expression without still having that pickwhip option, but thought I'd make it known, at least.

Any suggestions?


EDIT: I've got this ALMOST working, by using the "Separate XYZ Position" Preset, and applying this to one dimension:

seedRandom(index,true);
segDur = 1;
seed = index;
segStart = inPoint;
seedRandom(seed,true);
startVal = 0;
seedRandom(seed+1,true);
endVal = effect("X value")("Slider");
ease(time,segStart,segStart + segDur, startVal, endVal);

Being able to compile all dimensions into one position expression would be nice, though.

============================

Kyle Hamrick

Editor/Motion Graphics Artist

http://www.kylehamrick.com


Return to posts index

Dan Ebberts
Re: Move layer from fixed position to random position, within range
on May 26, 2010 at 4:32:24 am

Something like this maybe:


moveFrames = 30;
seedRandom(index,true);
startPos = [0,35,0];
endPos = random([-30,35,-20],[30,35,-80]);
ease(time,inPoint,inPoint+framesToTime(moveFrames),startPos,endPos)


Tying the min and max x and z values to sliders should be pretty straight forward.


Dan



Return to posts index

Kyle Hamrick
Re: Move layer from fixed position to random position, within range
on May 26, 2010 at 4:39:46 am

Thanks for the response Dan. Definitely more elegant than my solution.

Your post just barely beat me submitting my edit saying that I'd gotten it working. =)

Mine is still using my earlier expression nested into the "Separate XYZ" effect, but it's just as easy to copy/paste that. I was outlining my post a little more clearly in the hopes that it'd be helpful for someone else in the future.

Between your answer and mine, I think this thread has now served its purpose in that respect.

Thanks again!

Kyle Hamrick

Editor/Motion Graphics Artist

http://www.kylehamrick.com


Return to posts index

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