Activity › Forums › Adobe After Effects Expressions › Parent expression using Layer control effect
-
Parent expression using Layer control effect
Posted by Rafael Borges on July 30, 2009 at 10:43 pmI’m kindda new into expressions
So, I build a position random delayer preset that I can easily chose which object it will follow with a little delay, using the apparently useless layer control effect. It all works sweet, except for a little detail… when I chose the objcet it messes the layer original position.
How do I fix It?
check the code out:
target = effect(“Layer Control”)(“Layer”).position; //select which layes it will follow
seedRandom(effect(“Slider Control”)(“Slider”), true);// amount of randomness of time on the delay
target.valueAtTime(time – (random(1)));
So, how do I keep my original position when I apply this preset?
Tahnks
Neil Stubbings replied 15 years, 10 months ago 3 Members · 15 Replies -
15 Replies
-
Dan Ebberts
July 30, 2009 at 11:19 pmIt’s not clear to me what you want the expression to do. I’m especially confused about your tying the random seed to a slider. In any case, maybe a more precise description of the behavior you’re after would help.
Dan
-
Rafael Borges
July 30, 2009 at 11:48 pmWell, I want the expression to follow some other layer’s animation, for example, the position of a null object. But I want to be able apply that to multiple layers and to control the amount of delay that the they are going to follow the null. So that’s why I tied the seedRandom to the slider…guess that doesn’t work, isn’t it?
So that might be another problem on my expression!
Would make more sense if I tied the Random onto a sliders control instead of seedRandom?
Anyway, the delay on multiple layers following an animation of a null object works, but it messes the original position of the layers and I don’t want it to happen.
Hope I made myself clear. Sorry I’m not a native English speaker.
thanks a lot
p.s. I wore another code that might make more sense
-
Dan Ebberts
July 31, 2009 at 12:45 amTry this and see if it’s close to what you’re after. Set the slider to .5 to start with.
target = effect(“Layer Control”)(“Layer”).position; //select which layes it will follow
seedRandom(index, true);
delay = random(effect(“Slider Control”)(“Slider”));
delta = target.valueAtTime(time – delay) – target.valueAtTime(0);
value + deltaDan
-
Rafael Borges
July 31, 2009 at 3:56 pmDan it worked beautifully thank you so much!
I even adapted the expression to look at a slider control on the target object so it will give me easier control of the delay!
I created a preset out of it, if someone would like it just send me a e-mail. It is really useful especially if you’re working with thousands of layers
thanks again
-
Neil Stubbings
June 21, 2010 at 10:38 pmHello Dan
Is there any way to combine this delay expression with a springy expression?
So that the target object follows the motion of the leader in a springy dynamic way?I tried to combine your springy expression i found with this delay expression, but I had no luck 🙁
Also what would be great if the target object can still be animated individually.
I am trying to build a dynamic character rig for a rubbery character. So when I animate the torso the head follows in a dynamic way, and the hair follows the head in a dynamic way. But of course the head needs also to animate individual to the body.regards
Neil—
Neil Stubbings
Graphic Design | Motion Graphics
https://www.stubbings.ch
— -
Dan Ebberts
June 21, 2010 at 11:26 pmThe short answer is probably. You can combine expressions by calculating them separately, sticking the resulting values into variables and then combining the results. So you can have multiple things going on at the same time and can also combine those results with any keyframed animation by using +value. What were you going to use to trigger the spring motion?
Or, were you looking for a physical simulation where the inertia of the head causes the spring action when the body stops or starts? That’s a lot more complicated.
Dan
-
Neil Stubbings
June 21, 2010 at 11:40 pmwell simplified i want to do this:
say I have 3 Layers: RED, GREEN, BLUE while GREEN is at the bottom, RED is in the middle and BLUE at the top
I animate RED and GREEN follows RED with a delay and some springy motion.
At the same time BLUE follows GREEN also with a delay and some springy motion (so in the animation GREEN lags behind RED and BLUE lags behind GREEN)Now I also want to animate GREEN while RED does nothing and BLUE follows GREEN with a delay and springy motion.
In the end i want to add those expressions to puppet tool pins to get a wobbly character (much like a Barbapapa)
—
Neil Stubbings
Graphic Design | Motion Graphics
https://www.stubbings.ch
— -
Neil Stubbings
June 21, 2010 at 11:47 pmor just think about it being a sausage character with 3 pins.
one at the bottom, one in the middle and one at the top.
moving the bottom one causes the sausage to move like an antennae, because middle lags behind bottom and top lags behind middle (together with the springy motion)but in order to create more motion (maybe make the sausage speak) the middle pin needs to be animated while the top one still keeps wobbling top the middle one’s motion, but the bottom one stays where it is…
is my explanation as complicated as I think it is
—
Neil Stubbings
Graphic Design | Motion Graphics
https://www.stubbings.ch
— -
Dan Ebberts
June 21, 2010 at 11:54 pmAgain, I think the complexity boils down to what controls/triggers the springy motion.
Dan
-
Neil Stubbings
June 22, 2010 at 10:01 amuhm, ok let me put it this way:
I want this expression:
target = effect("Layer Control")("Layer").position; //select which layes it will follow
seedRandom(index, true);
delay = random(effect("Slider Control")("Slider"));
delta = target.valueAtTime(time - delay) - target.valueAtTime(0);
value + deltacombined with this expression
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;
}—
Neil Stubbings
Graphic Design | Motion Graphics
https://www.stubbings.ch
—
Reply to this Discussion! Login or Sign Up