Activity › Forums › Adobe After Effects Expressions › Easier Effectors?
-
Easier Effectors?
Posted by Ben Coello on July 28, 2008 at 2:42 pmHey thanks for checking this post!
I really love Dan Ebberts Inverse Kinematics Redux for animating 2d characters, and especially like how I can use motion sketch on the effector layers to “puppet” my character.
This made me think it’d be nice to do something simpler where I use an effector to control the rotation of just a single layer, such as the character’s torso. I’m imagining it would be a relatively simple expression that keeps the layer pointed towards the effector.
Thanks for the help.
Ben Coello replied 17 years, 9 months ago 2 Members · 8 Replies -
8 Replies
-
Dan Ebberts
July 28, 2008 at 9:23 pmTry this:
L = thisComp.layer(“effector”);
P = L.toWorld(L.anchorPoint);
V = P – toWorld(anchorPoint);
radiansToDegrees(Math.atan2(V[1],V[0]))Dan
-
Ben Coello
July 28, 2008 at 10:24 pmThank you Dan, it works like a charm…
…except…
It seems as though the effector wants to be to the right of the layer, and as it just so happens my art is all oriented to the left, so how would I go about modifying the expression so that rotation is at zero degrees when the effector (I was actually thinking that calling it a handle is a nicer term) is to the left or possibly above it’s layer.
This is probably a really basic thing, but as I’m sure is clear I’m totally new to expressions and all this scripting business.
I also have an additional question here (I feel kind of like I should be paying for this) a similar thing to another post of mine, but slightly different. Is it possible to limit the rotation on the effected layer so it won’t rotate to far in either direction, past the point where things look wonky?
Thanks in advance. These forums are awesome.
-
Dan Ebberts
July 28, 2008 at 10:50 pmThis should work for either side:
L = thisComp.layer(“handle”);
P = L.toWorld(L.anchorPoint);
V = P – toWorld(anchorPoint);
if (V[0] > 0){
radiansToDegrees(Math.atan2(V[1],V[0]))
}else{
radiansToDegrees(Math.atan2(V[1],V[0])) + 180
}Dan
-
Ben Coello
July 29, 2008 at 12:39 amDan you are an officer and a gentleman. Thank you.
Looking at the two expressions, I was able to figure out that I could add a number to the end of line four in the first expression, and place the handle at whatever angle to the layer that I chose. So I learned something too.
thanks again.
-
Ben Coello
July 30, 2008 at 4:48 pmHey Dan,
I hope you (or anyone else who might know a thing or two about expressions) can help me one more time here. After fully rigging my model and playing around with it a bit, I discovered one unforeseen problem.
I attempted to link together a series of layers with separate handles. Head, to Neck, to Torso, each parented to the next, and then I parented the handles to the parent of whatever they control (eg The head handle is parented to the neck) What I discovered is that when I rotate the neck layer, the head will rotate some, and then when I rotate the torso, the head and neck both rotate, even though the relationship to their respective handles doesn’t change.
I thought this might be because the handles are taking their positional data from the world of the composition, but I tried just moving the model around, and everything works as it should. So I’m at a loss here. Any help for this expressions klutz is appreciated.
thanks
-
Ben Coello
July 30, 2008 at 4:50 pmSorry for the double post here, I realized I shouldn’t have replied to myself…
Hey Dan,
I hope you (or anyone else who might know a thing or two about expressions) can help me one more time here. After fully rigging my model and playing around with it a bit, I discovered one unforeseen problem.
I attempted to link together a series of layers with separate handles. Head, to Neck, to Torso, each parented to the next, and then I parented the handles to the parent of whatever they control (eg The head handle is parented to the neck) What I discovered is that when I rotate the neck layer, the head will rotate some, and then when I rotate the torso, the head and neck both rotate, even though the relationship to their respective handles doesn’t change.
I thought this might be because the handles are taking their positional data from the world of the composition, but I tried just moving the model around, and everything works as it should. So I’m at a loss here. Any help for this expressions klutz is appreciated.
thanks
-
Dan Ebberts
July 30, 2008 at 5:43 pmGood point. The calculation should probably be done in the layer space of the layer being rotated to allow for the rotation of layers up the parent chain.
Try this:
L = thisComp.layer(“handle”);
P = fromWorld(L.toWorld(L.anchorPoint));
V = P – anchorPoint;
if (V[0] > 0){
radiansToDegrees(Math.atan2(V[1],V[0]))
}else{
radiansToDegrees(Math.atan2(V[1],V[0])) + 180
}Dan
Reply to this Discussion! Login or Sign Up