Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Having an issue calculating the distance between my camera and a Null with an expression!?

  • Having an issue calculating the distance between my camera and a Null with an expression!?

    Posted by Aza Allen on July 10, 2012 at 4:52 am

    length(transform.position, thisComp.layer(“Focus Control”).transform.position)

    I have this expression above on the “Focus Distance” for my camera, I have the Null object with a layer parented to it…

    I am trying to keep the camera focused on the Null as I move it around, but as you can see below, it’s giving me a Distance greater than the distance to my object and I have no idea why!

    Can someone help?

    Thanks!

    My portfolio can be seen at http://www.ruesterprod.com
    My personal website is http://www.azaallen.com

    Aza Allen replied 13 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Walter Soyka

    July 10, 2012 at 2:04 pm

    Your screenshot shows that the camera is parented to a null. That means that its position is relative to its parent — it cannot be used in a length calculation with an object that is not a sibling. In other words, the camera and the focus control are working in two coordinate systems with different frames of reference.

    We must therefore convert the camera’s position to world coordinates:

    length(thisComp.activeCamera.toWorld([0,0,0]),thisComp.layer("Focus Control").transform.position)

    Walter Soyka
    Principal & Designer at Keen Live
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    RenderBreak Blog – What I’m thinking when my workstation’s thinking
    Creative Cow Forum Host: Live & Stage Events

  • Aza Allen

    July 10, 2012 at 9:44 pm

    Thank you very much…. wow, I had no idea the coordinate systems changed depending on parent/child relationships!

    My portfolio can be seen at http://www.ruesterprod.com
    My personal website is http://www.azaallen.com

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