You can make Beam follow the layers even if they move in Z space. Put this expression in the position for your beam points. (Replacing BOX LAYER NAME HERE with the respective box’s layer name, of course.)
Now, if you want the beam to change perspective…I don’t have that sort of expression handy, but it’s probably been covered before, search the forums.
thisComp.layer("BOX LAYER NAME HERE").toComp([0,0,0]);
– The Great Szalam
(The ‘Great’ stands for ‘Not So Great, in fact, Extremely Humble’)
No trees were harmed in the creation of this message, but several thousand electrons were mildly inconvenienced.