2 Replies Latest reply on Sep 2, 2011 6:43 AM by Matelot13

    How can I link the two ends of a stroke to another item?


      I'm just learning AE, so maybe this is obvious...

      But I wad first told that you van't animate points separately... There must be a way, though...


      Thanks for any advice...





        • 1. Re: How can I link the two ends of a stroke to another item?
          Rick Gerard Adobe Community Professional & MVP

          I have an old tutorial on my site that shows you exactly how to do this. Unfortunately I've changed servers so right now the links to the project and the movie are broken on the site. You know the saying, the coblers children have no shoes. That's me and my site. Maybe this is motivation to get it fixed up and update the info once in a while.



          Here's the basics from the tutorial:


          I created a layer called String and a layer called Kite. I drew an open mask on the String layer that shaped a gentle arc, added the Stroke effect with a width of 3 pixels and Paint on Transparent selected. The stroke goes from the left edge to the right edge of the String layer, and that's important. The String layer is slightly narrower than the comp to make it easy to work with. The last step with the String layer is to move the anchor point to the left most vertice point of the mask at exactly an X value of 0. this is also important. Both layers are converted to 3D.

          The Kite layer is simply a square solid with a kite shaped mask and the anchor point moved to where the string would attach.

          The following expressions are added to the string layer:
          String Scale:

          point1 = position;
          point2 = thisComp.layer("Kite").position;
          L = length(point1, point2);
          w = thisLayer.width;
          r = L/w*100;

          [r, value[1], value [2]]

          String Orientation:

          t = thisComp.layer("Kite");
          l = thisComp.layer("String");

          fromPoint = l.position
          atPoint = t.position
          lookAt(fromPoint, atPoint)

          If you look carefully at the language you'll see that I'm calculating the distance between the anchor points and then dividing the distance by the layer width and multiplying that number by 100 to arrive at a scale factor so that the String layer is always the same length as the distance between the end of the string and the kite. The Orientation part of the expression simply points the string at the kite. There is one problem that must be overome. The string layer is perpendicular to the Kite so, and this part is important, the Y rotation must be changed to -90 to get things back to normal. This isn't another expression, it's just a value you put in.

          The Kite layer also needs an expression to point the kite at the end of the string. The Kite orientation expression is basically the same as the String Orientation expression with definitions for the from and at point reversed. It looks like this:
          Kite Orientation:

          t = thisComp.layer("String");
          l = thisComp.layer("String");

          fromPoint = t.toWorld(position);
          atPoint = l.toWorld(thisComp.layer("String").anchorPoint);
          lookAt(fromPoint, atPoint)


          Now the kite can be moved around and the string will follow. All you have to do to attach the end of the string to another solid is to make the solid a 3D layer, place it in the correct position, and parent it to the string.


          Here's a project file.

          1 person found this helpful
          • 2. Re: How can I link the two ends of a stroke to another item?
            Matelot13 Level 1

            Wow, I'm going to have a studious week-end


            Thank you very much