Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random position start from specific position

  • Random position start from specific position

    Posted by Nikolay Vladimirov on December 13, 2015 at 10:49 pm

    Hi I’m trying to get some object start to move random from one figure with this expression added to position:
    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 the problem is when I add the expression the object position on the first frame now is in random position – can i get it to start from specific position?

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

    December 13, 2015 at 11:56 pm

    Try this one:


    minDur = .3;
    maxDur = .7;
    vMin = [0.1*thisComp.width, 0.1*thisComp.height];
    vMax = [0.9*thisComp.width, 0.9*thisComp.height];
    seedRandom(index,true);
    tNext = tPrev = inPoint;
    n = 0;
    while (tNext <= time){
    tPrev = tNext;
    tNext += random(minDur,maxDur);
    n++;
    }
    seedRandom(tPrev,true);
    vPrev = (n == 1) ? value : random(vMin,vMax);
    seedRandom(tNext,true);
    vNext = random(vMin,vMax);
    ease(time,tPrev,tNext,vPrev,vNext);

    Dan

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