Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Dumper truck w. Hydraulic arm

  • Dumper truck w. Hydraulic arm

    Posted by Anders Hattne on March 14, 2011 at 10:06 pm

    Hi,
    I’m trying to link this hydraulic pole of the loading bit of a dumping truck.

    ..That “loading bit” is lifted and the pole consisting of two parts extends out.
    I’ve managed to tie the bottom part of the hydraulic arm to the top bit, with this expression..

    c = thisComp.layer("Medium Red Solid 2");
    offset = effect("Slider Control")("Slider");
    otherDimension=c.to_comp(c.anchor_point);
    diffx = thisLayer.position[0]-otherDimension[0]
    ;
    diffy = position[1]-otherDimension[1];
    if (diffx == 0) {diffx = 1 }sign = 1 + (-1 * (diffx / Math.abs(diffx))) * 90;
    radians_to_degrees(Math.atan(diffy/diffx)) + sign + offset

    That way It always looks at where hydraulic part 2 is connected. Unfortunately I can’t get the upper part to look at the lower.

    My apologies for writing a messy post. I added the image in an attempt to clarify the problem.

    http://www.ardillamedia.com

    Anders Hattne replied 15 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 14, 2011 at 10:43 pm

    Here’s how I’d do it. I’d position a null (“Null 1”) at the point where you want the pole to attach to the tilting bed and make the bed the parent of the null. I’d lay out the two pieces of the hydraulic arm horizontally, with the pole positioned so that its right edge aligns with the right edge of the shorter, wider piece. Then make the wider piece the parent of the pole. Use an expression like this for the wide piece’s rotation:

    diff = thisComp.layer(“Null 1”).toWorld([0,0,0]) – toWorld(anchorPoint);
    radiansToDegrees(Math.atan2(diff[1],diff[0]))

    and one like this for the position of the pole:

    p0 = parent.toWorld([parent.width,parent.height/2]);
    p1 = thisComp.layer(“Null 1”).toWorld([0,0,0]);
    value + length(p0,p1)

    Dan

  • Anders Hattne

    March 15, 2011 at 8:55 pm

    Hey! Thanks Dan, It works!
    I tried the same set up on a different scenario with some sort of excavator and then it went all a bit funny.
    I guess it has to do with the parenting, but then I figure the toWorld function should deal with that no matter how many links of parenting there is.
    I’ll keep trying, but for the tilting bed it works!

    Thanks again!

    http://www.ardillamedia.com

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