Intelligent Camera Switching Using Clearshot Cameras
Cinemachine’s Clearshot Camera, is yet another prebuilt component that makes use of childed Virtual Cameras. Using Cinemachine Collider extensions, allows the Clearshot Camera to calculate which child has the least obstructed view of the target object, and thus set that child as the active camera.
This component largely functions with the same parameters as a normal Virtual Camera, but we can also define rules on if and when cameras can change, as well as randomizing choice when two cameras with a clear view have the same priority.
Setting up a few separate obstacles, we can select through our three child cameras and see which one has the clear shot.
Now, as we navigate the obstacles we can see our Clearshot Camera in action! Using a multi-camera system such as this can be super beneficial for non-POV third person games, as we can never know where exactly a user is going to move their player. With different combinations of Aim and Body properties, this could very easily capture all sorts of intricate camera works.