Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Can you use expressions on compositions?

  • Can you use expressions on compositions?

    Posted by Will Burroughs on January 7, 2019 at 9:32 pm

    I am putting together my first AE project and can’t get an expression (inertia bounce) to work on a composition. I have created a composition (grouped elements) comprising of a laptop and web page which scrolls vertically within the laptop screen. The laptop animates in vertically off canvas moving into position before the web page scrolls. I wanted the laptop to have some bounce back once in position but the inertia bounce expression won’t work? I have tried this on with a shape layer and it worked perfectly so guessing that expressions will not work on compositions?

    e = .7;
    g = 5000;
    nMax = 9;

    n = 0;
    if (numKeys > 0){
    n = nearestKey(time).index;
    if (key(n).time > time) n--;
    }
    if (n > 0){
    t = time - key(n).time;
    v = -velocityAtTime(key(n).time - .001)*e;
    vl = length(v);
    if (value instanceof Array){
    vu = (vl > 0) ? normalize(v) : [0,0,0];
    }else{
    vu = (v < 0) ? -1 : 1;
    }
    tCur = 0;
    segDur = 2*vl/g;
    tNext = segDur;
    nb = 1; // number of bounces
    while (tNext < t && nb <= nMax){
    vl *= e;
    segDur *= e;
    tCur = tNext;
    tNext += segDur;
    nb++
    }
    if(nb <= nMax){
    delta = t - tCur;
    value + vu*delta*(vl - g*delta/2);
    }else{
    value
    }
    }else
    value

    Dan Ebberts replied 7 years, 4 months ago 3 Members · 3 Replies
  • 3 Replies
  • Jeff Kay

    January 7, 2019 at 10:17 pm

    Looks like when you copy and pasted the expression the < signs got replaced by < No idea if that happened inside of AE or when you posted.

    I don’t know what you mean when you ask if it will work “on a composition”. The thing that it may or may not work on is a particular property which may be on a composition or any other layer. Though because this particular expression uses value I don’t see an issue of it returning the wrong type of value (e.g. returning an array of 1 when the property expects an array of 2, or a color value).

    The property in question must actually be animated. The expression provides the bounceback specifically by calculating that change. If the property is not animated then the expression is correctly working when it does nothing.

  • Will Burroughs

    January 7, 2019 at 11:06 pm

    Thanks for the response Jeff Kay. I checked and the expression does work on compositions. I made a test composition and it was fine. The composition I am animating does move from one point to another so this should work but it isn’t and don’t know why. The only thing I have done differently is to adjust the keyframe velocity. Would this have an effect?

    FYI this is where I got the expression from:
    https://docs.google.com/document/d/12ymsMLNA0oiIZc8_iXS9zuEMUH1NGV1zbvwnHkm21DM/edit

  • Dan Ebberts

    January 7, 2019 at 11:57 pm

    If you ease the keyframe such that there’s little or no velocity when you reach the keyframe, then you get little or no bounce.

    Dan

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