-
Repel/Attracting layers and random generator
Hello!
I’m newb at expressions so I killed a lot of time tryin to achive ‘repel’ effect. Then I found Colin Braley article https://www.colinbraley.com/repel_expressions_tutorial.html
I’ve tried to use Repel (Attracting) Expression (basic version) in 3D and it’s still working. Awesome!avoidPos = thisComp.layer(“Attracted Layer”).position;
maxDisplacement = thisComp.layer(“Controls”).effect(“max disp”)(“Slider”); //maximum amount to move the layer
minDistance = thisComp.layer(“Controls”).effect(“min distance”)(“Slider”); //minimum distance to begin displacing at
//–
vec = avoidPos – position;
directionVec = normalize( vec );
distance = length( vec );
displaceAmt = ease( distance , 0 , minDistance , 0, maxDisplacement );
displacementVec = displaceAmt * directionVec;
position + displacementVec;Exactly what I need.
But can anyone help me with combining this expression with another (Andrew Kramer’s generator of random positions for the layers):
X=wiggle(0,thisComp.layer(“RandomControl”).effect(“X”)(“Slider”))[0];
Y=wiggle(0,thisComp.layer(“RandomControl”).effect(“Y”)(“Slider”))[1];
Z=wiggle(0,thisComp.layer(“RandomControl”).effect(“X”)(“Slider”))[2];
[X,Y,Z]So I can generate random positions for the multiple copies of the layers but they still will be respond to the movement of Attracting Layer.
One of the expressions just don’t work if another pasted below.
Probaly I must edit this line “position + displacementVec” and add this random positions values to this. But I don’t know how.English is not my native language so I hope someone will understand this.
I will be very grateful for help.