Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions expression help: bounce to final position

  • expression help: bounce to final position

    Posted by Gabrielle Dainard on May 26, 2016 at 1:50 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])
    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 = 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!!

    thank you in adcance

    <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)

    Gabrielle Dainard replied 10 years, 3 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy