-
random movement
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