Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Continuously refocusing camera

  • Continuously refocusing camera

    Posted by Will Barry on March 26, 2007 at 2:28 am

    Hi there,
    I am pretty new to expressions so bear with me…
    I have a camera that is dollying forward in z-space, and all the elements are out of focus in the comp. As it moves forward, I want it to re-focus on particular layers that are at different z-spaces. I want the camera to make smooth pull-focus like transitions as it refocuses on each layer.
    Obviously this would take a while to animate manually, so is it possible to set eased’focus distance’ keyframes in the timeline with an expression on each one of the keyframes telling it to focus on the relevant layer? If so, how?
    Hope that all made sense. Would really appreciate any help people could give, as it’d save me a hell of a lot of time.
    Thanks,
    Will

    Colin Braley replied 19 years, 2 months ago 3 Members · 2 Replies
  • 2 Replies
  • Mike Clasby

    March 26, 2007 at 4:24 am

    I think this might do what you want, it’s worth a try.

    Click Dan Ebbert’s head and Scroll down to:

    Building the World’s Greatest Cameraman
    using After Effects 5.5’s Expression Controls

    In the final comp, “Pan, Tilt and Focus & Zoom” , if you disable the random expressions for the target layer, Dan, Evol, James and Larry, then spread them out on the Z, then if you animate the camera’s position (Camera 1), you get what you want… methinks. The layers focused on are controlled by Slider Control in the Null 1 layer. So by keyframing the correct layer order number, you get the camera to focus in the order you want.

  • Colin Braley

    March 26, 2007 at 4:51 am

    Something like this should do the trick, as long as none of your layers are parented to anythiing. Just create a null named “Controls” and add a slider called “layer index” Then keyframe “layer index” as the number of the layer you want to focus on. Then add the expression below to the focus distance property of your camera.

    layerIndexSwitch =thisComp.layer(“Controls”).effect(“layer index”)(“Slider”);
    nearestKey = layerIndexSwitch.nearestKey( time );
    nextKey = layerIndexSwitch.key( nearestKey.index );
    distanceOne = length( position – thisComp.layer( nearestKey.value ).position );
    distanceTwo = length( position – thisComp.layer( nextKey.value ).position );
    ease( time, nearestKey.time, nextKey.time, distanceOne, distanceTwo )

    I wrote this one really quick and didnt test it much so let me know if you have any problems.
    ~Colin

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