# Linking depth of field focus to Null? - Adobe After Effects

This is a discussion on Linking depth of field focus to Null? - Adobe After Effects ; What's the best way to link the focus of my camera to a null? I want the DoF seperated from the point of interest. I just want to move a null around to change what the camera is focused on ...

1. ## Linking depth of field focus to Null?

What's the best way to link the focus of my camera to a null? I want the DoF seperated from the point of interest. I just want to move a null around to change what the camera is focused on (which may or may not be where the camera is aimed at the moment).

2. ## Re: Linking depth of field focus to Null?

Focus distance is measured in pixels. All you have to do is add an expression to the Focus distance of the camera that measures the length from the null to the camera. The Expression Language Menu has a category called Vector Math . In that category you'll find the following: length(point1, point2) All you have to do is replace point1 with position and point2 with thisComp.layer("Null 1").position

The final expression looks like this:

length(position, thisComp.layer("Null 1").position)

Now, no matter where you put your null, the camera will be focused on that point. It couldn't be much simpler.

Rick

3. ## Re: Linking depth of field focus to Null?

Thanks for the explanation Rick.

So if you had Null 1 and Null 2, it'd be
length(thisComp.layer(Null 1").position, thisComp.layer("Null2").position) ?

So that calculates how far apart 2 nulls are?

4. ## Re: Linking depth of field focus to Null?

If the null isn't on the camera's z axis, you need to do a little vector math to align the camera's focal plane with the null. An expression like this for the camera's Focus Distance should do it:

v1 = thisComp.layer("Null 1"). position - position;
v2 = toWorldVec([0,0,1]);
dot(v1,v2)

Dan

5. ## Re: Linking depth of field focus to Null?

Hey David! What are your plans for using the distance between two nulls?