Intelligent Camera Switching- Game Dev Series 183

S.J. Jason Liu
3 min readMar 13, 2023

--

Objective: using ClearShot Camera to create target-detecting camera system.

As a gamer since 1997, which game series effected me the most is Resident Evil series, especially the first 2 titles of this whole series.
One of the special feature of these 2 games is the fixed camera system.

This camera system provides terrifing to players who could not see the whole environment they are in it.
On the otherhand, this system requires setting multiple cameras with a perferct working system to detect where main character goes to.

Luckly, we have Cinemachine that can create this system easily that you won’t even need to write a single line of code to complete.

ClearShot Camera

In dropdown menu of Cinemachine, there is an option called “ClearShot Camera”, which is what we are going to use today.

Before we import this camera system, we need to prepare an environment to demonstrate its powerful.
I’ve created multiple walls and put Danny into game scene.

Then we can create a ClearShot Camera into game scene.
Here are 2 ways to add more virtual camera into ClearShot Camera game object: you can either add it from its virtual camera children column, or simply add more virtual camera and drag them into this gameobject.

The 1st way

But notice that if you are dragging cameras into ClearShot Camera gameobject, make sure add a collider extension to all the camers, or there will be a warning message in ClearShot Camera.

Once done adjusting the position of all cameras, make sure that all cameras are set to look at main character.

For now, you can set Follow to “Do nothing” for a better demonstration.

All done, let’s play test to check how it works.

As you can see, when a camera is blocked by a wall, the system would automatically switch to a camera that can locate target, and that is pretty close to the system we mentioned in the beginning of this article- Resident Evil style.

--

--

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.