Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Puppet Physics. PuppetTools + Elastic Connection

  • Puppet Physics. PuppetTools + Elastic Connection

    Posted by Nathan Clark on December 21, 2013 at 6:51 pm

    Hey guys,

    Im having a bit of a struggle trying to hack together 2 expressions.

    I have used the script PuppetToolsV3 from AEscripts to connect a puppet pin to a null.

    Expression: fromComp(thisComp.layer("MyPuppet | Puppet Pin 1").toComp(thisComp.layer("MyPuppet | Puppet Pin 1").anchorPoint));
    But now I would love to add some of Ebberts’ Elastic Connection magic from MotionScript to the equation.

    Expression:restLength = 20;
    damp = .95;
    leader = thisComp.layer("leader");

    fDur = thisComp.frameDuration;
    currFrame = Math.round(time / fDur);

    p2 = position.valueAtTime(0);
    v2 = 0;
    for (f = 0; f <= currFrame; f++){
    t = f*fDur;
    p1 = leader.transform.position.valueAtTime(t);
    delta = p2 - p1;
    nDelta = normalize(delta);
    a = 2 * nDelta * (length(delta) - restLength) * fDur;
    v2 = (v2 - a) * damp;
    p2 += v2;
    }
    p2

    Can someone please help me work out how to ‘smoosh’ these together,
    so the puppet pin follows the null with some elastic physics?
    I can’t quite work out how to make it work.

    Thanks in advance 🙂

    Nathan Clark replied 12 years, 4 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    December 21, 2013 at 8:07 pm

    This should be close:


    restLength = 20;
    damp = .95;
    leader = thisComp.layer("MyPuppet | Puppet Pin 1");

    fDur = thisComp.frameDuration;
    currFrame = Math.round(time / fDur);

    p2 = valueAtTime(0);
    v2 = 0;
    for (f = 0; f <= currFrame; f++){
    t = f*fDur;
    p1 = fromComp(leader.toComp(leader.anchorPoint,t));
    delta = p2 - p1;
    nDelta = normalize(delta);
    a = 2 * nDelta * (length(delta) - restLength) * fDur;
    v2 = (v2 - a) * damp;
    p2 += v2;
    }
    p2

    Dan

  • Nathan Clark

    December 22, 2013 at 10:07 am

    Hi Dan,

    Indeed it is close 🙂 thanks for having a look at this! There is a limitation that I would love to circumvent if at all possible?

    Currently, by design, it’s problematic to reposition the initial location of the leader null. The puppet pin tries to stay where it is, with the tension then pulling it to the new location of the null (I assume this is because the expression is referencing the initial position of the pin, rather than the null?).

    This is explained better the short screencapture below. Is this something that can be changed easily enough? So the initial position of the pin is locked to the null?

    Puppet Physics – Troubleshooting 01

  • Dan Ebberts

    December 22, 2013 at 10:10 pm

    If you start the leader layer at a position that makes its distance from the pin equal the restLength (20 in my example), then the pin should start in its initial position at time=0.

    Dan

  • Nathan Clark

    December 23, 2013 at 7:48 pm

    Yep thanks, I just needed to adjust how I initialize my rig’s pose. Its working fantastically, thanks a lot Dan!

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