Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions random movement

  • Posted by Wouter Bruneel on June 29, 2009 at 7:27 pm

    hey,

    I’ve put togetehr this expression to move a square randomly over a grid based on the domensions of the comp.

    segDur = .5;// duration of each “segment” of random motion
    minVal = [0.1*thisComp.width, 0.1*thisComp.height];
    maxVal = [0.9*thisComp.width, 0.9*thisComp.height];
    aantalkolommen =8
    gap = 0.9*thisComp.width/aantalkolommen;
    aantalrijen = Math.floor(thisComp.height/gap);
    seed = Math.floor(time/segDur);
    segStart = seed*segDur;
    seedRandom(seed,true);
    startVaX = gap + gap*Math.floor(random(aantalkolommen));
    seedRandom(seed,true);
    startVaY = gap + gap*Math.floor(random(aantalrijen));
    seedRandom(seed+1,true);
    endVaX = gap + gap*Math.floor(random(aantalkolommen));
    seedRandom(seed+1,true);
    endVaY = gap + gap*Math.floor(random(aantalrijen));
    vergX = startVaX/endVaX;
    vergY = startVaY/endVaY;
    if ( vergX>vergY)
    {finalx = startVaX;
    finaly = endVaY;
    }
    else
    {finaly = startVaY;
    finalx = endVaX;
    };
    startVal = [startVaX,startVaY];
    endVal = [finalx, finaly];
    ease(time,segStart,segStart + segDur, startVal, endVal);

    The problem is that the square moves the way i want it between but after a movements it seems to grab a new random position in the grid. In oher words it jumps to a new position. Any ideas as to why this happens?

    thanks,

    W

    Wouter Bruneel replied 17 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies

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