Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions line ends to follow object

  • line ends to follow object

    Posted by Andy Engelkemier on July 22, 2011 at 2:20 pm

    I did a quick search and found that you can’t do an expression to control path point. That was my first thought. So I wanted to ask you guys if you think if this could have been done more efficiently, faster, whatever.

    I have 3 objects. A circle, a triangle, and a line connecting them.

    I have both objects linked to the circle so I can rotate it as needed.

    On the circle I have a slider named “Line Length”

    I didn’t want to mess with the scale so much, so first I moved the triangle to 100, then scaled the line to the correction position manually.

    I added in a slider “ScaleMult” to add some slight tweaks if I needed them, but once I got set to starting from 100 it was much easier to do the simple math.

    These objects are all illustrator, but the line could have been drawn in AE also. There’s nothing special about it really.

    All this really is is a stylized arrow to match some other presentations of a similar project done a while ago by someone else (print only). So I thought I’d ad some familiarity by reusing it, but adding some subtle animations like it growing out of wherever, but it’s going to be a bunch of different lengths so I thought I’d make a script to control the line, and a slider to control the length.

    So now all I have to do is move the circle around, choose the rotation of the line, and animate the length.

    Could this have been done in a better way?

    line code:
    - scale:
    scaleMult = effect("ScaleMult")("Slider") ;
    lineLength = thisComp.layer("circle").effect("Line Length")("Slider");
    x = transform.scale[0];
    y = transform.scale[1] *( scaleMult / 100) * lineLength;
    [x,y];

    triangle code:
    -position:
    lineLength = thisComp.layer("circle").effect("Line Length")("Slider") ;
    x = (transform.position[0]);
    y = ( lineLength*-1);
    [x,y];

    Kevin Camp replied 14 years, 10 months ago 2 Members · 3 Replies
  • 3 Replies
  • Kevin Camp

    July 22, 2011 at 3:42 pm

    if you created the line with the beam effect, then you could use the expression pickwhip to link one end point of the beam to the circle, and the other to the triangle (change the colors, softness, thickness and length as needed).

    that would then always draw a line connecting the other 2 shapes, no matter where you placed them.

    to get the triangle to rotate so it always points away from the circle, you could use an expressionlike this:

    target = thisComp.layer(“Circle”).transform.position;
    p = sub(target, position);
    radiansToDegrees(Math.atan2(p[1], p[0])) – 90

    the -90 at the end of the expression assumes that the triangle’s initial orientation was upwards, if your triangle’s original orientation was a different direction, just modify that value.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Andy Engelkemier

    July 22, 2011 at 3:48 pm

    Beam Effect, I like your thinking. That’s a great idea. I always think of that as some sort of laser use. I’ve never actually used it.

    I kind of like having the triangle orientation be automatic as well. My current plan is a bit more awkward to position. Your solution seems a bit nicer.

    Thanks.

  • Kevin Camp

    July 22, 2011 at 4:07 pm

    [Andy Engelkemier] “I always think of that as some sort of laser use.”

    yep.. i’m sure that was the intended use, though i’ve never actually used it like that 😉

    your current setup wasn’t too bad… it only required 2 keyframes for each change (rotation and the length slider). you could actually add an angle expression control to control the rotation, then all adjustments would be in the effect controls, rather than going back and forth from effect controls and layer properties.

    the beam method could be as simple as animating the triangle position.

    if it was 3d, it would get a bit trickier with the expressions.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

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