fredag den 22. november 2019

Rebound bounce

With this expression, you can create a rebound effect of the object from the floor. Allows you to animate almost any parameter.


e = .3; // Bouncing
g = 1; // Gravity
nMax = 10; // Maximum bounces

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*1000);
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*1000)*delta/2);
}else{
value
}
}else
value
AE POSTWORK blog is virtually just a notepad, where I put all the AE expressions up I finde and use, its so I can easily get to them wherever I am and no matter what computer I sit at. I do not write my own expressions, so all expressions on the page is downloaded from the web,or modify versions i found. and tutorials etc.. I will try to credit those who have made expressions if I can.

Now, with tips and tricks for AE & C4D.
No more forgetting the little tricks and tips I found on my road with After Effects, etc.

Sebabba