-
parenting functionality with expressions
Hi all
I am trying to build more or less complex character rigs with expressions and ran into the following problem.
I got this (see below) code off the fabulous AEenhancers forum, which has some coding masterminds as members.
basicly what it does, is follow a “leader” (body) layer with a delay and a springy motion to create dynamics.so I have this “leader” layer and this “head” layer.
The “head” layer has the below expression so it follows the “leader” and creates a dynamic motion.
But of course the “head” is locked by the expression, so i can not animate it independently.All I need is the same behavior as if I would use parenting: the “head” follows the “leader”‘s motion but can also be animated to the character can move its head.
any ideas in how to change the expression?
cheers
Neil———–
Neil StubbingsP = thisComp.layer("leader").position;delay = 0.8; // link to a slider for easy tweaking
de = delay*thisComp.frameDuration*(index-thisComp.layer("leader").index);F = thisComp.layer("leader").position.valueAtTime(time-de);
xyz = position.valueAtTime(0) - thisComp.layer("leader").position.valueAtTime(0);
n = 0;
if (P.numKeys > 0){
n = P.nearestKey(time).index;
if (P.key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - P.key(n).time;
}if (n > 0){
v = P.velocityAtTime(P.key(n).time - thisComp.frameDuration/10);
amp = 0.05; // link to a slider for easy tweaking
freq = 2; // link to a slider for easy tweaking
decay = 2; // link to a slider for easy tweaking
F + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t) + xyz;
}else{
F + xyz;
}