ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Can you use expressions on compositions?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Will Burroughs
Can you use expressions on compositions?
on Jan 7, 2019 at 9:32:46 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];
vu = (v &lt; 0) ? -1 : 1;
tCur = 0;
segDur = 2*vl/g;
tNext = segDur;
nb = 1; // number of bounces
while (tNext &lt; t && nb &lt;= nMax){
vl *= e;
segDur *= e;
tCur = tNext;
tNext += segDur;
if(nb &lt;= nMax){
delta = t - tCur;
value + vu*delta*(vl - g*delta/2);

Return to posts index

Jeff Kay
Re: Can you use expressions on compositions?
on Jan 7, 2019 at 10:17:25 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.

Return to posts index

Will Burroughs
Re: Can you use expressions on compositions?
on Jan 7, 2019 at 11:06:20 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:

Return to posts index

Dan Ebberts
Re: Can you use expressions on compositions?
on Jan 7, 2019 at 11:57:08 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 All Rights Reserved