-
Sing Along Rubbery Bouncing Ball to any tempo changes
I haven’t found a way to do this yet but,
I’m trying to set an expression for null object that will be used as a parent for different bouncy balls for sing-along types of videos.
I’ve been using this expression so far:
BounceHeight = 60;
if (numKeys < 2){
position;
}else{
nextKey = nearestKey(time).index + 1;
prevKey = nearestKey(time).index - 1;
if (time >= nearestKey(time).time){
if (nextKey > numKeys){
freq = 1;
}else{
freq = 1 / (2 * (key(nextKey).time - nearestKey(time).time));
}
}else{
if (prevKey <= 0){
freq = 1;
}else{
freq = 1 / (2 * (nearestKey(time).time - key(prevKey).time));
}
}
posSin = Math.abs(Math.sin(freq * (time - nearestKey(time).time) * 2 * Math.PI));
y = BounceHeight * posSin;
position - [0,y];
}However with songs with abrupt tempo changes this ends up looking really bad. … to put lightly. lol.
Side note:
I also like the idea of this “rubbery” effect experssion does on the bounce:
// Inertial Bounce (moves settle into place after bouncing around a little)
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - key(n).time;
}if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
amp = .05;
freq = 4.0;
decay = 2.0;
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value;
}So would anyone be willing to share an expression so that the speed of the ball bounce changes to whatever the distance on X axis is between key frames with the bottom of the bounce hitting on that keyframe, AND with a slight rubber effect on the bounce? Gotta love those Coke Zero commericals. Well, anyway, having the speed of the bounce to dynamically adjust to the
space between X-axis keyframes will allow position keyframes on syllables so no matter what speed the tempo is going it will work and look good.If you figure this out you are a genius!
The world thanks you.