Intelligent Camera Switching Using Clearshot Cameras

Dennisse Pagán Dávila
4 min readJan 16, 2023

A clear shot Camera uses child cameras to determine the best shot of a given Look At target. By strategically placing child cameras in your scene, you can use the Clear shot camera to automatically alternate between them making sure to always prioritize the one with the best view.

Objective: Learn how to use Clearshot cameras to alternate views. In this example, we’ll be taking a look at two child cameras that change view whenever the character(Look At target) is out of sight.

Table of Contents

· Setting Up the Clearshot Camera and Child Cameras
· The Result

You can catch up with all my Cinemachine articles here.

Setting Up the Clearshot Camera and Child Cameras

  1. Let’s start by going to the Cinemachine menu and adding our camera.

2. Add a Look At target, this is the object the camera will prioritize into view. In this case, this is my character.

The clear shot camera has its own integrated area for child cameras, in fact, you may notice that when adding the clear shot camera, it automatically comes with a child attached to it.

3. Now, we want to take a look at the child camera. Adjust it to any view you like. It doesn’t matter how you move it, its rotation will always remain fixated on the Look At target.

4. We need another child camera. Technically, you can add many as you like but I will stick to two for this example.

5. Make sure to tweak the Avoid Obstacles checkbox on the Cinemachine Collider component of each of the cameras. This makes it so the cameras won’t run into objects that have colliders causing them to clip through or cause other odd angles.

Also, since the Body settings aren’t doing anything for this example, we set this to Nothing.

Note: It is possible to drag and drop cameras into your clear shot camera and make them into child cameras which will retain the same functionality. However, when adding them this way, always make sure to add the Cinemachine Collider(Script) to them or you will get a warning message.

6. Adjust your cameras to different positions.

Here is where the strategic placement of child cameras comes into play:

  • I have the camera set in the corridor where my character starts at.
  • My second camera will be set outside the corridor because once my character exits that area, he will effectively be out of sight. This will prompt my clear shot camera to find the next most convenient way to get the character into view again, that option is given by the second camera.

Admittedly, my character could be more outside of the camera's 2 views, but these angles ended up working for me when tested.

The Result

I hope you have found this information valuable! Follow me for more Unity Development articles! :) I am a writer and Unity Developer on a journey to join the video game industry.

Check out my LinkedIn and Twitter!

--

--

Dennisse Pagán Dávila

Software Engineer that specialize in Game Development. Currently looking for new opportunities. LinkedIn: https://rb.gy/xdu8nu