Start with Elasticity & End with Overshoot
Posted: January 22nd, 2015, 2:45 pm
Hey guys,
i am trying create an expression that makes my animation elastic at the start and overshoot at the end using ease n wizz script.
the script can't animate with elasticity and overshoot at the same time, so i am trying to manipulate the functions..
at this point, the result is like this one
but i need something like this
I am really stuck
i am trying create an expression that makes my animation elastic at the start and overshoot at the end using ease n wizz script.
the script can't animate with elasticity and overshoot at the same time, so i am trying to manipulate the functions..
at this point, the result is like this one
but i need something like this
I am really stuck
Code: Select all
// some defaults
var p = 0.8; // period for elastic
var a = 50; // amplitude for elastic
var s = 1.70158; // overshoot amount for "back"
(easeAndWizz() || value);
function customFunc(t, b, c, d, a, p) {
var keyCheck = false; // change to "true" if you want to invert the animation order..
try {
if (key(2).time > time) {
keyCheck = 1 - keyCheck;
} //keyCheck
} catch (e) {
return null;
}
if (!keyCheck) {
// inBack Function
return c * (t /= d) * t * ((s + 1) * t - s) + b;
} else {
// elastic_out function
if (t == 0) return b;
if ((t /= d) == 1) return b + c;
if (!p) p = d * .3;
if (!a || a < Math.abs(c)) {
a = c;
var s = p / 4;
} else var s = p / (2 * Math.PI) * Math.asin(c / a);
return (a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b);
}
}
function easeAndWizz() {
var n = 0;
if (numKeys > 0) {
n = nearestKey(time).index;
if (key(n).time > time) {
n--
}
}
try {
var key1 = key(n);
var key2 = key(n + 1);
} catch (e) {
return null;
}
// determine how many dimensions the keyframes need
var dim = 1; // It's gotta have at least ONE dimension
try {
key(1)[1];
dim = 2;
key(1)[2];
dim = 3;
} catch (e) {}
t = time - key1.time;
d = key2.time - key1.time;
sX = key1[0];
eX = key2[0] - key1[0];
if (dim >= 2) {
sY = key1[1];
eY = key2[1] - key1[1];
if (dim >= 3) {
sZ = key1[2];
eZ = key2[2] - key1[2];
}
}
if ((time < key1.time) || (time > key2.time)) {
return value;
} else {
val1 = customFunc(t, sX, eX, d, a, p, s);
switch (dim) {
case 1:
return val1;
break;
case 2:
val2 = customFunc(t, sY, eY, d, a, p, s);
return [val1, val2];
break;
case 3:
val2 = customFunc(t, sY, eY, d, a, p, s);
val3 = customFunc(t, sZ, eZ, d, a, p, s);
return [val1, val2, val3];
break;
default:
return null;
}
}
}