Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Move layer from fixed position to random position, within range

  • Move layer from fixed position to random position, within range

    Posted by Kyle Hamrick on May 26, 2010 at 4:03 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

    Kyle Hamrick replied 15 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 26, 2010 at 4:32 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

  • Kyle Hamrick

    May 26, 2010 at 4:39 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

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