ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Aza Allen
Having an issue calculating the distance between my camera and a Null with an expression!?
on Jul 10, 2012 at 4:52:07 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


Return to posts index


Walter Soyka
Re: Having an issue calculating the distance between my camera and a Null with an expression!?
on Jul 10, 2012 at 2:04:21 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


Return to posts index

Aza Allen
Re: Having an issue calculating the distance between my camera and a Null with an expression!?
on Jul 10, 2012 at 9:44:09 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]