Jacob Roth
Forum Replies Created
-
Works like a dream! Thanks Dan.
-
Thanks everybody.
What I ended up doing was creating one column through the motion tile width setting, then duplicating that comp as many times as I needed. Then I made a control layer for odds, one for evens, and then phase got time*x or -x depending on odd or even. It worked, but was a pretty heavy render.
-
Now I can’t seem to define xLim. Error at line 46, xLim is missing or does not exist.
content = thisLayer.sourceRectAtTime();
left = content.width/2;
top = content.height/2;
right = thisComp.width-content.width/2;
bottom = thisComp.height-content.height/2;minSpeed = 100; //pixels per second
maxSpeed = 100;minX = left + 20;
maxX = right - 20;
minY = top + 20;
maxY = bottom - 20;minR = 5;
maxR = 85;seedRandom(index,true);
// calc start position
pos = random([minX,minY],[maxX,maxY])
quadrent = Math.floor(random(4))*90;
angle = random(minR,maxR) + quadrent;
spd = random(minSpeed,maxSpeed);// initialize time count;
t = 0;
while(t <= time){
rads = degreesToRadians(angle);
xVel = spd*Math.cos(rads);
yVel = spd*Math.sin(rads);// see if going up or down
if (yVel < 0) yLim = (yVel < 0) ? top : bottom;
// see if going right or leftif (xVel < 0) xLim = (xVel < 0) ? left : right;
timeX = (xLim - pos[0])/xVel;
timeY = (yLim - pos[1])/yVel;if (timeX < timeY){ //hit left or right wall
if (t + timeX >= time){
deltaT = time - t;
pos += [xVel,yVel]*deltaT;
break;
}else{
pos = [xLim,pos[1] + yVel*timeX];
angle = 180 - angle;
t += timeX;
}
}else{ //hit upper or lower wall
if (t + timeY >= time){
deltaT = time - t;
pos += [xVel,yVel]*deltaT;
break;
}else{
pos = [pos[0] + xVel*timeY,yLim];
angle = 360 - angle;
t += timeY;
}
}
}
pos -
Sorry, that’s not right. The error is at line 32, and it’s a timeout waiting for the engine.
rads=degreesToRadians(angle);
-
Thanks for the response.
Subbing your suggestions gives me an error at line 65, which is…
t += timeY;
-
Hi Dan,
This expression is great, but is there any way for the layer to bounce at its layer edges and not the anchor point?
-
Are you trying to get the source text to reflect marker comments? If so, here’s your code.
m = thisComp.layer("Your Layer"); // source text layer name inside parens and quotes
n=0;
if (m.marker.numKeys > 0){
n = m.marker.nearestKey(time).index;
if (m.marker.key(n).time > time) n--;
}
if (n > 0) m.marker.key(n).comment else "" -
Dan Ebberts has a random grid at motion script.
https://www.motionscript.com/expressions-lab-ae65/random-grid-movement.html
-
You could add a transform effect. That would give you a second Scale attribute.