Intelligent Camera Switching Using Clearshot Cameras

Jared Amlin
3 min readJun 2, 2022

Let us keep exploring these Cinemachine preset cameras by taking a look at the Clearshot Camera. This powerful feature will select the camera that has an unblocked view of the target, so let’s get started using it.

Either use the Cinemachine drop down at the top of your screen, or head to the Hierarchy and add a Cinemachine>Clear Shot Camera. By default you will get a Clear Shot camera parent with a single virtual camera child.

Use the plus (+) icon in the inspector on the Clear Shot parent to add additional cameras.

Each virtual camera in the Clear Shot parent will need a Cinemachine Collider extension. By default this is added when making cameras in the inspector. If you drag an existing virtual camera into the Clear Shot parent, you will probably need to add the collider extension.

All four cameras are assigned the 3D model of the Player to the Look At target. Other than that, these cameras will be stationary.

The Avoid Obstacles option must be enabled on all child virtual cameras for this usage of the Clear Shot camera to work.

I first setup some walls for my player to run around, blocking cameras as they all try to Look At the target.

Each camera is placed near the inner corner to assure the player will be blocked from view while running in circles.

Here in the scene view the player runs a circle around the obstacle.

Here in the game view, the cameras change to show the one that has a ‘clear shot’ of the target!

I hope you enjoyed this short article on clear shot cameras and thanks for reading!

--

--

Jared Amlin

I am an artist and musician, that is currently diving headfirst into game development with C# and Unity3D.