Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions DVD Logo Style Bouncing Layer Expression

  • Sebastian Smith

    May 29, 2019 at 10:04 pm

    hey filip,using this expression results in an error. do you know whats wrong with it?

  • Filip Vandueren

    May 29, 2019 at 11:08 pm

    See my post just below it, The forum scramblers Some of the “less than” symbols

  • Sebastian Smith

    May 30, 2019 at 12:14 am

    okay it fixed it but the thing im using doesnt have the same dimensions on x and y,so kinda goes a bit over the border on the left and the ride side of the comp. how would i fix that/control that?

  • Sebastian Smith

    May 30, 2019 at 8:55 pm

    cant figure it out. 🙁

  • Filip Vandueren

    May 30, 2019 at 10:15 pm

    You would need 2 separate margin-variables

    H_margin=150;
    V_margin=80;

    And then use those where needed.

  • Sebastian Smith

    June 3, 2019 at 8:20 pm

    thanks,is there a way to loop this expression

  • Filip Vandueren

    June 3, 2019 at 8:34 pm

    The best way to loop it is to find hSpeed and vSpeed such that they eventually wind up at the same place again.

    Here’s the expression changed so you can set it to loop at a certain time and a certain number of H en V bounces

    hMargin= 100; // how far the anchorpoint of the layer has to stay from the edges of the comp.
    vMargin= 50

    cw=thisComp.width - hMargin*2;
    ch=thisComp.height -vMargin*2;

    loopTime = 5; // seconds

    // next two should be integers, preferably not divisible by each other,
    // for high numbers I recommend prime numbers
    hLoops = 3;
    vLoops = 4;

    t=time%loopTime;

    hSpeed = hLoops*2*cw/loopTime;
    vSpeed = vLoops*2*ch/loopTime;

    // calculate the layer moving at a constant speed
    x = value[0] - hMargin + t*hSpeed;
    y = value[1] - vMargin + t*vSpeed;

    // keep the layer in bounds
    x = x<0 ? -x : x;
    x%=2*cw;
    x = x>cw ? (2*cw)-x : x;

    y = y<0 ? -y : y;
    y%=2*ch;
    y = y>ch ? (2*ch)-y : y;

    [x,y]+[hMargin,vMargin]

  • Shai Ezra

    August 4, 2019 at 5:40 pm

    Thank you very much! It worked perfectly!

    I don’t understand expressions too well but copy-paste this to the position expression worked.

    I also got the errors… I located the problematic lines in the expression and just deleted them, the effect didn’t change. You could even change the speed by changing the values. more luck than brains haha

    once again thank you my friend (:

Page 2 of 2

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