Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Falling Null attached to another null so it swings

  • Falling Null attached to another null so it swings

  • Graham Quince

    January 30, 2021 at 3:03 pm

    I feel like I’m really close with this, but I’m stuck. I’m trying to have one Null parented to another, but have it fall due to gravity. I want this constrained so that when it hits the maximum length it starts to swing under.

    I thought clamp() would help, but I can’t see how to manage the X position.

    g = 10; // gravitational constant
    y = g*time*time/2;
    xPos = value[0];
    yPos = clamp(y,0,250);
    [xPos,yPos];

    Any ideas?

  • Graham Quince

    January 30, 2021 at 5:02 pm

    I’m getting closer, I realised I can use @danebberts bounce expression to describe the x movement swinging in:

    g = 10; // gravitational constant

    y = g*time*time/2;

    xPos = value[0];

    yPos = clamp(y,0,250);

    if (yPos == 250) {

    t = time - inPoint;

    startVal = xPos;

    endVal = 0;

    dur = 0.1;

    xPos = linear(t,0,dur,startVal,endVal);

    }

    [xPos,yPos];

    I just have to figure out how to set t to not be based on the inPoint, but the moment when Y crosses the 250 threshold.

  • Graham Quince

    January 30, 2021 at 5:54 pm

    I’m getting closer, but it’s still the time that’s the issue, I need to replace the inPoint value with the timestamp from when y is clamped.

    xPosStart = 1200;

    yPosStart = 540;

    parentPos = thisComp.layer("Null 1").transform.position;

    gravity = 10;

    distance = length(transform.position,thisComp.layer("Null 1").transform.position);

    rope_length = 400;

    if (distance >= rope_length){ // once the null is at the max length of the rope, kick in Dan Ebberts's overshoot expression

    t = time - xStartTime;

    freq = 3;

    decay = 5;

    startVal = [xPosStart,y];

    endVal = [parentPos[0],parentPos[1]-rope_length/2];

    dur = 0.1;

    if (t < dur){

    linear(t,0,dur,startVal,endVal);

    } else {

    amp = (endVal - startVal)/dur;

    w = freq*Math.PI*2;

    endVal + amp*(Math.sin((t-dur)*w)/Math.exp(decay*(t-dur))/w);

    }

    } else { // Fall straight down, until at end of rope

    xStartTime = time;

    yPos = gravity*100*time*time;

    y = clamp(yPos,yPosStart,yPosStart+rope_length);

    [xPosStart,y];

    }

    It’s not giving me an error, but it’s stopping

Viewing 1 - 3 of 3 posts

Log in to reply.

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