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