Activity › Forums › Adobe After Effects Expressions › Auto secondary movement (inertia/overshoot) in children layers
-
Auto secondary movement (inertia/overshoot) in children layers
Fabian Brugger replied 4 years, 6 months ago 7 Members · 29 Replies
-
Eduardo Oliveira
April 25, 2016 at 11:43 pmif all you want is postional oveshoot ( like the original bounce), you can try this:
i haven’t got AE open at the moment, so if it does not work let me know.//inertial children bounce
n = 0;
amp = .04;
freq = 2.0;
decay = 3.0;ppos=thisLayer.parent.transform.position;
if (ppos.numKeys > 0){
n = ppos.nearestKey(time).index;
if (ppos.key(n).time > time){
n--;
}
}
if (n == 0){
ppos.velocity[0]
t = 100;
}else{
t = time - ppos.key(n).time;
}if (n > 0){
v = ppos.velocityAtTime(ppos.key(n).time - thisComp.frameDuration/10)*-1;value + v[0]*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value
} -
Jake Dickey
April 26, 2016 at 2:02 amRE:Rotation
Ah, that’s what I was afraid of. I’m looking for a way to attach a lot of objects to a null, or other parent object, and I want them to have inertial bounce based on the movement of the null. Kind of the same idea add what you have here, but instead of rotational manifestation, I just need good old fashioned directional inertial bounce, for lots of objects all tied to one parent.
-
Eduardo Oliveira
April 26, 2016 at 7:08 amthis last expression that posted should do it! just drop it on the “position”
-
Jake Dickey
April 26, 2016 at 1:01 pmYes, indeed it did! Looking over the code, I can sort of see what I was doing wrong with my attempts. I understand the flow and logic of it, I just don’t understand the correct “grammar” of AE Java when it goes beyond just referencing the layer where the code originated–and I stumble my way through that anyhow. Thank you!
-
Jake Dickey
April 26, 2016 at 1:48 pmJust as a side note, I modified this line:
v = ppos.velocityAtTime(ppos.key(n).time - thisComp.frameDuration/10)*-1;to…
v = ppos.velocityAtTime(ppos.key(n).time - thisComp.frameDuration/10)*1;By changing the -1 at the end to a positive value, that got things closer to what I needed. It seems with a negative value, the velocity curve (and bounce response) is more like its falling at a constant speed and bouncing off of a hard surface like a rubber ball when it reaches the end position–at least, on the first bounce. With a positive value, it seems to let the children follow through past the end position, dissipating their “inertia” on the other side of the axis, like they are buoyant objects that fell into water, or like the children are tethered to the parent via loose springs on an imaginary Z axis.
if (n > 0){
v = ppos.velocityAtTime(ppos.key(n).time - thisComp.frameDuration/10)*1;value + v[0]*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value
} -
Eduardo Oliveira
April 26, 2016 at 1:53 pmwell spotted. i think this *-1 was still left over from the other expression, and unnecessary for yours. more so, you dont even need to multiply it by 1, as this does absolutely nothing =DDD
below you’ll find those lines revised.
if (n > 0){
v = ppos.velocityAtTime(ppos.key(n).time - thisComp.frameDuration/10);value + v[0]*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value
} -
Jake Dickey
April 26, 2016 at 2:41 pmFair enough. I will probably leave it in anyway so that it is easier for me to remember what value to change if I DO want a collision type bounce.
-
Jake Dickey
April 26, 2016 at 2:44 pmOh crap. So, this works great on the x axis, but it doesn’t do anything on the y axis. I don’t understand the code well enough to understand why. Any ideas on getting this code to work in both (or even 3) axis simultaneously?
-
Eduardo Oliveira
April 26, 2016 at 2:56 pmtry this:
//inertial children bounce
n = 0;
amp = .04;
freq = 2.0;
decay = 3.0;ppos=thisLayer.parent.transform.position;
if (ppos.numKeys > 0){
n = ppos.nearestKey(time).index;
if (ppos.key(n).time > time){
n--;
}
}
if (n == 0){
ppos.velocity
t = 100;
}else{
t = time - ppos.key(n).time;
}if (n > 0){
v = ppos.velocityAtTime(ppos.key(n).time - thisComp.frameDuration/10)*-1;value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value
} -
Eduardo Oliveira
April 26, 2016 at 2:57 pmsorry, i forgot aobut the -1
here is the correct version:
//inertial children bounce
n = 0;
amp = .04;
freq = 2.0;
decay = 3.0;ppos=thisLayer.parent.transform.position;
if (ppos.numKeys > 0){
n = ppos.nearestKey(time).index;
if (ppos.key(n).time > time){
n--;
}
}
if (n == 0){
ppos.velocity
t = 100;
}else{
t = time - ppos.key(n).time;
}if (n > 0){
v = ppos.velocityAtTime(ppos.key(n).time - thisComp.frameDuration/10);value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value
}
Reply to this Discussion! Login or Sign Up