Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Puppet Tool IK?

  • Gleb Rysanov

    August 10, 2009 at 6:46 pm

    I’m obviously not Dan, but I do feel grateful to him for all the knowledge he shares. Maybe it’s time to pay a tiny bit back to the community he represents. I recently worked on a character animation project and found it quite tortureous to animate puppet tool limbs manually. so, a friend of mine has written these expressions and granted authorization to post them here. the idea is to animate rotation and bending of a limb through manual animation of one single puppet pin only (wrist/foot). the elbow/knee shall be making natural movements being parented to the wrist/foot through expression. the shoulder/hip shall stay in place, serving as rotation axis.

    1. expression for the wrist/foot (for a 3-point limb like leg or arm):

    // Character Animation — Puppet Tool Inverse Kinematic:
    // simulating a three-joint (puppet pins) limb movement
    // through one single joint animation.
    // This expression is for Puppet Pin 3 (wrist or foot)
    if (time < 0) { B = value; } else { A = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 1").position.valueAtTime(-1); B = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 3").position.valueAtTime(-1); C = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 2").position.valueAtTime(-1); BC = thisComp.layer("Bending Controller").transform.position; T = thisComp.layer("Puppet Controller").transform.position; R1 = length(A, C); R2 = length(B, C) A = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 1").position; d = length(A, T); if (d > R1 + R2) {
    B = add(A, mul(sub(T, A), (R1+R2)/d));
    }
    else {
    B = T;
    }
    }
    B

    2. expression for the elbow/knee (for a 3-point limb like leg or arm):
    // Character Animation — Puppet Tool Inverse Kinematic:
    // simulating a three-joint (puppet pins) limb organic movement
    // through one single puppet pin animation.
    // This expression is for Puppet Pin 2 (elbow)
    if (time < 0) { C = value; } else { A = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 1").position.valueAtTime(-1); B = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 3").position.valueAtTime(-1); C = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 2").position.valueAtTime(-1); BC = thisComp.layer("Bending Controller").transform.position; T = thisComp.layer("Puppet Controller").transform.position; R1 = length(A, C); R2 = length(B, C) A = effect("Puppet").arap.mesh("Mesh 1").deform("Puppet Pin 1").position; d = length(A, T); if (d > R1 + R2) {
    C = add(A, mul(sub(T, A), R1/d));
    }
    else if (d < 1.0) { C = add(A, mul(sub(BC, A), R1/length(BC, A))); } else { B = T; a = ((R1 * R1 - R2 * R2 + d * d) / (2 * d)); h = Math.sqrt(R1 * R1 - a * a); D = add(A, mul(sub(B, A), a/d)); C1 = [D[0] + h * (B[1] - A[1]) / d, D[1] - h * (B[0] - A[0]) / d]; C2 = [D[0] - h * (B[1] - A[1]) / d, D[1] + h * (B[0] - A[0]) / d]; try { S1 = length(C1, BC); S2 = length(C2, BC); if (S1 < S2) { C = C1; } else { C = C2; } } catch(e) { C = add(A, mul(sub(BC, A), R1/length(BC, A))); } } } C To get these running, you'll obviously need to apply the Puppet Tool to your character's limb so that the Puppet Pin's numbers are as follows: (1) shoulder/hip, (2) elbow/knee and (3) wrist/foot. You'll have to create two Null Objects and name them "Puppet Controller" and "Bending Controller." Puppet Pin 3 is parented to the first one through expression and the whole animation should be done through this Null. The second one determines direction of the limb bending, depending on this Null position respective to imaginary line between Pins 1 and 3. And, finally, to move or rotate the limb as a whole it's advisable to nest your limb comp into new one, where you can safely manipulate by the limb comp as a layer without ruining your puppet animation. I personally prefer to parent the "Puppet Controller" to another Null in a parent composition so I can have access to any kind of animation from one single place. That's it -- helped my a lot. By the way, the author of these expressions is a freelancer programmer Anatoliy Moskovsky (avm@sqlbatch.com), so feel free to contact him shopuld you feel like it's time to let expressions do all the hard work for you 😉

  • Assassa Antani

    November 3, 2009 at 9:49 am

    Hi everyone, first post for me!
    Ehi Gleb, thank you for your help with the puppet tool! I only have one little problem…I can’t get it to work! When I enter the expression in the position of the puppet pin point, it returns me an error message and the expression gets disabled. Her’s the warning:

    After Effects warning: Expected: )
    Expression disabled.

    Error occurred at line 6
    Comp:’OMINO’
    Layer:3(‘Braccio_SX’)
    Property:’Position’

    I think I did everything you said in your post. Is there something I’m missing? Maybe I have to rename the layer or the comp in a particular way? Is it possible for you to post a test file just to get a look at how you do it? Maybe I’m asking too much! Anyway thank you again!

  • Gleb Rysanov

    February 12, 2010 at 5:48 pm

    Hello Emmanuele,

    It’s hard to say what’s wrong with your setup — the texts of the expressions have been tested and worked well, if applied properly. Judging by the text of the error, there must be a missing bracket somewhere in the layer’s expressions.
    Make sure you’ve rigged your character properly and applied expressions to respective pin points positions (not layer position).

    Hope this will help!

Page 2 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy