Auto-Zoom Camera to See All Players?

Nice! @ClockworkOcean clokworkoc Thank you. This is something I have planned for a combat system.

After reading this topic yesterday I started prototyping and got about halfway to what I wanted. Suddenly 7+ hours had past and it was 5am to end with something that is probably extreamly overcomplicated. :rofl:

If you guys would like to keep this topic alive or start a new one to share ideas, I’m all for it.

Some quick thoughts for perpetuity:

  • From the cameras perspective I get the furthest actors top, left, bottom and right. This means looping through all of them per side.
  • I get their center and calculate the distance from left-> right and top → down to build a bounding box from the cameras perspective.
  • Finnaly (and the part where I passed out) I calculate the distance the spring arm has to be from the center taking into account the fixed width and FoV. This only takes into consideration horizontal, need to integrate vertical somehow.

This is how it looks like… not perfect but it’ll get there:
CameraZoomOnPlayers


  • Converting world location to screen is another alternative I was considering to redice the math a bit.
  • I did not take into account depth, so actors can go behind the camera. Think a solution is to always keep the spring arm a minimum distance from the closest actor to the camera looking from center out and have its length adjust if necesary.
  • Getting the center of the group is easy but an actor that is furthest in both vertical and horizontal can heavily influence the location.
2 Likes