-
Random position from index AND looping wiggle
Ok, I’m getting a little in the weeds here, and could use a second pair of eyes on this code.
I’ve set up a layer to randomly position its self in 3D based on its index, but now I also need to make sure every layer has a subtle bit of random movement, that can be looped. At the moment my code mostly works, however looping is an issue. The position seems to pop to a certain place, and then run, but then when it reaches the end of the loop, pops to a different position.
seedRandom(index,true);
s = thisComp.layer("Seed").effect("Seed")("Slider");//random position setup. The mods allow me to adjust spread in x,y,z with sliders
xMod = thisComp.layer("Seed").effect("X_Mod")("Slider");
yMod = thisComp.layer("Seed").effect("Y_Mod")("Slider");
zMod = thisComp.layer("Seed").effect("Z_Mod")("Slider");
a = [-s*xMod, -s*yMod, -s*zMod];
b = [s, s, s];//wiggle setup
wigFreq = thisComp.layer("Seed").effect("WigFreq")("Slider");
wigAmp = thisComp.layer("Seed").effect("WigAmp")("Slider");
loopTime = 2;
t = time % loopTime;wiggleX1 = wiggle(wigFreq, wigAmp, t);
wiggleX2 = wiggle(wigFreq, wigAmp, t - loopTime);
wiggleY1 = wiggle(wigFreq, wigAmp, t);
wiggleY2 = wiggle(wigFreq, wigAmp, t - loopTime);
wiggleZ1 = wiggle(wigFreq, wigAmp, t);
wiggleZ2 = wiggle(wigFreq, wigAmp, t - loopTime);
X=linear(t, 0, loopTime, wiggleX1, wiggleX2)[0];
Y=linear(t, 0, loopTime, wiggleY1, wiggleY2)[1];
Z=linear(t, 0, loopTime, wiggleZ1, wiggleZ2)[2];position.value + random(a,b)+[X,Y,Z]; //this might be the culprit, as I don't think I'm combining these different variables properly