Keeping All Objects In View in Unity

Tyler Smallwood
3 min readDec 16, 2022

--

Objective: Set up a camera to keep all multiple objects in it’s view!

If we wanted to create a multiplayer game and wanted to keep all players in the same view. Well with Unity we can easily do that with Cinemachine. We’ll start by adding in a Target Group Camera.

When we add this Target Group Camera, it’ll populate a Virtual camera and a TargetGroup.

If we select the Virtual Camera, we will see that it already has the TargetGroup as Follow and LookAt.

What we will really have to focus on for this article is the TargetGroup.In here we can set the objects that it’ll need to keep in view.

I’m going to create 2 more 3D Objects for this to keep track of.

Back in the TragetGroup, let’s add 3 targets by hitting the plus.

Slide each of the objects into one of the spots.

Now if we move any object around, the camera will zoom in and out on the objects. Farther apart each object is from one another the more zoomed out it’ll be.

In the TargetGroup, we can see that each object has a Weight and Radius attribute. Weight will have the camera focus on that object more than the others. The Radius is radius of the object, it will help keep the bounding box a little bit bigger.

More about this can be found in the documents.

Now we have the opportunity to make a mechanic similar to Super Smash Bro. Thank you for reading and have a wonderful day.

--

--

Tyler Smallwood
Tyler Smallwood

Written by Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer

No responses yet