Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions parenting functionality with expressions

  • parenting functionality with expressions

    Posted by Neil Stubbings on June 16, 2010 at 8:12 pm

    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 Stubbings

    P = 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;
    }

    Neil Stubbings replied 16 years ago 2 Members · 3 Replies
  • 3 Replies
  • Trent Armstrong

    June 17, 2010 at 5:52 pm

    Sometimes it’s just necessary to include the value of the transform property as well.

    Try replacing with this line:

    xyz = position.valueAtTime(0) – thisComp.layer(“leader”).position.valueAtTime(0) + value;

    Trent Armstrong – Creative Cow Leader
    https://www.dallasaeug.com

  • Neil Stubbings

    June 17, 2010 at 7:51 pm

    wow, great thanks! works perfect!

    cheers
    neil


    Neil Stubbings
    Graphic Design | Motion Graphics
    https://www.stubbings.ch

  • Neil Stubbings

    June 21, 2010 at 6:06 pm

    hey

    somehow, i do not get this to work anymore… strange

    try to do this simple thing:
    – create a leader layer
    – create a few following layers and apply the expression and said ” + value;” expression

    the layers do not stay on their initial position. they jump to some other position. This of course totally messes up my puppet rig.

    any ideas?

    cheers
    Neil


    Neil Stubbings
    Graphic Design | Motion Graphics
    https://www.stubbings.ch

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