Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Parenting nulls to trigonometry-controlled objects

  • Parenting nulls to trigonometry-controlled objects

    Posted by Thomas Hannen on February 8, 2016 at 2:15 pm

    I want to build a digram with arrows between some boxes, where the arrows are connected to the edges of the boxes. So if I move the boxes around, the arrows with change length and angle.

    I’ve read tutorials about how to connect lines to other objects dynamically, using the Beam effect, but I want arrows!

    Using this post – https://forums.creativecow.net/thread/227/6984 I was able to build an arrow that is controlled by two nulls (at the start and end).

    But when I try to parent one of the start or end nulls to another null or object, the parent object doesn’t move the child object.. What am I missing?

    video example here.

    Below are some snippets of my dodgy code:

    arrowlength controlled by

    <code>CellTower = thisComp.layer("startpoint").transform.position;
    Target = thisComp.layer("endpoint").transform.position;
    sizefactor = 100/(effect("ArrowSize")("Slider"));
    BeamLength = (length(CellTower, Target)*sizefactor)-150;
    [BeamLength]
    </code>

    rotation of the arrow controlled by

    <code>CellTower=thisComp.layer("startpoint").transform.position;
    Target=thisComp.layer("endpoint").transform.position;

    // Find the length of side a
    SideA = sub(CellTower, Target)[1];

    // Find the length of side b
    SideB = sub(CellTower, Target)[0];

    //Find the Angle between them
    -1*(270-(radiansToDegrees(Math.atan2(SideA, SideB))+180));</code>

    Kalleheikki Kannisto replied 10 years, 3 months ago 2 Members · 5 Replies
  • 5 Replies
  • Kalleheikki Kannisto

    February 8, 2016 at 5:34 pm

    For your consideration:

    9764_puppetpinarrow.aep.zip

  • Thomas Hannen

    February 8, 2016 at 8:42 pm

    Hi,
    Thanks for the suggestion… I thought about using puppet pins, but I really wanted to keep the geometry of the arrows just right – they seem to look fine though, unless they’re really short.

    Having said that, I still can’t get the two nulls to parent to other objects without everything breaking.
    I really need to be able to dynamically move some boxes attached to the arrows.

    Here are my steps:

    * Load your .aep project
    * Make a shape – a rounded rect box
    * Change it’s anchor point (using, but could just as easily be a manual adjustment)
    * Duplicate the shape
    * Change shape two’s anchor point
    * Reposition the arrow nulls into the right places
    * Parent Null 1 (the base of the arrow) to Shape 1

    See video here:
    https://www.youtube.com/watch?v=bed23MzoUUU

    Immediately the arrow shape jumps off to the side. Why?

    Many thanks again for the suggestion.

  • Thomas Hannen

    February 8, 2016 at 8:46 pm

    I’ve just realised, if I re-write the expression on the puppet pin to point to the shape layer it solves my problem!

    Many thanks-

    I’m still stumped as to why I can’t parent a null to another null successfully though…

  • Thomas Hannen

    February 8, 2016 at 9:19 pm

    Also, by adding a Layer Selector to the expression, I can choose which object the arrow starts and ends from:

    Based on the excellent tutorial by Felt Tips here: https://vimeo.com/104381026

    try {
    L = effect("Arrow Base")("Layer");
    } catch(e) { // catch an error in case layer is set to None. Stops expression crashing
    L = false;
    }
    if(L)
    fromWorld(L.position);
    else value

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Vimeo framework” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • Kalleheikki Kannisto

    February 9, 2016 at 11:54 am

    Parenting messes up the coordinate transformation, and it can get complex. I often end up using “value +” (or a specific value) to change the position. You can get it to work with expressions as well, but I don’t personally find figuring out the right combination of fromComp/toComp/fromWorld/toWorld very easy with a more complex setup, so I just take the easier way.

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