FORUMS: list search recent posts

# expression help: bounce to final position

FAQ   •   VIEW ALL
 expression help: bounce to final position on May 26, 2016 at 1:50:03 pmLast Edited By Gabrielle Dainard on May 26, 2016 at 6:25:34 pm

hello,
i am trying to bounce multiple copies of a logo off the sides of my comp for 3 seconds then they all land in the center of my screen.
i have found two expressions that work as i need them to but i dont know how to combine them.

LOGO BOUNCE:

left = 0;
top = 1070;
right = thisComp.width;
bottom = thisComp.height;

minSpeed = 800; //pixels per second
maxSpeed = 100;

minX = left + 20;
maxX = right - 20;
minY = top + 0;
maxY = bottom - 20;

minR = 5;
maxR = 85;

seedRandom(index,true);

// calc start position

pos = random([minX,minY],[maxX,maxY])
spd = random(minSpeed,maxSpeed);

// initialize time count;

t = 0;

while(t <= time){

// see if going up or down

if (yVel < 0) yLim = top else yLim = bottom;

// see if going right or left

if (xVel < 0) xLim = left else xLim = 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

FINAL POSITION

moveDur = .5;
seedRandom(index,true);
startPos = random([thisComp.width,thisComp.height]);
ease(time,inPoint,inPoint+moveDur,startPos,value)

if anyone has any feedback for me that would be amazing!!

```<b>LOGO BOUNCE:</b> left = 0; top = 1070; right = thisComp.width; bottom = thisComp.height; minSpeed = 800; //pixels per second maxSpeed = 100; minX = left + 20; maxX = right - 20; minY = top + 0; 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 &lt;= time){ rads = degreesToRadians(angle); xVel = spd*Math.cos(rads); yVel = spd*Math.sin(rads); // see if going up or down if (yVel &lt; 0) yLim = top else yLim = bottom; // see if going right or left if (xVel &lt; 0) xLim = left else xLim = right; timeX = (xLim - pos[0])/xVel; timeY = (yLim - pos[1])/yVel; if (timeX &lt; 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 <b>FINAL POSITION</b> moveDur = .5; seedRandom(index,true); startPos = random([thisComp.width,thisComp.height]); ease(time,inPoint,inPoint+moveDur,startPos,value)```