This page looks best with JavaScript enabled

Smooth Multi-Point Following Camera

 ·   ·  ☕ 1 min read

    You have multiple characters or points that you want on camera. How do you do that? This is how.

    This solution solves the problem of keeping multiple objects on screen by creating a dynamic camera that tracks a rectangle. This rectangle is created by the min/max of the XY positions of tracked objects. Once the rectangle is created a border is added around the outside so the players aren’t on the edge of the screen. By moving the camera to the center of this we get a good XY position. To solve for the Z coordinate of our camera we need to project out the camera a certain distance. What distance depends on the field of view of our camera and can be solved using a formula kindly provided by Unity already (link below). This allows us to precisely calculate the distance in order to fit our rectangle on the visible screen.

    Once we have all three of those coordinates we know where to position our camera, then it’s just about moving it there.

    The unity documentation page we got the frustum calculations from is here:


    Sam Wronski
    Sam Wronski
    Maker of things, currently helping build cloud things @ Google. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!