The Cinemachine Brain is the literal brains of your Cinemachine system. It is responsible for blending multiple virtual cameras and controlling the final output to the scene view. The virtual cameras are created using the Cinemachine Virtual Camera component, and each virtual camera has its own settings such as lens settings, field of view, and more. The virtual cameras can be linked together to form a timeline of camera shots, making it possible to create complex camera movements, such as follow cameras and cutscenes.
The brain takes input from the virtual cameras and blends them based on the current active virtual camera. This can be controlled through the Brain’s Priority value, which determines the order of the virtual cameras. The Priority value is set on each virtual camera and the virtual camera with the highest priority value will be used as the final output. The blending between virtual cameras can also be customized using the LookAt and Follow properties of the virtual cameras, providing a smooth transition between camera shots. In addition the brain has the ability to add noise to the virtual camera’s position and orientation. This can be useful for creating a more natural and dynamic camera movement, such as simulating a handheld camera or adding jitters to a steadicam shot. The noise can be customized using the Noise settings in the virtual camera component, and can be controlled based on time, position, and orientation.
A good example of this is creating a simple Security System. In the scene below I have set up a few cubes in the shape of a hall way with a Trigger cube placed in the center. Attached to the trigger is a script that will trigger when the player.
At the end of each “hall” is a camera, this is a static camera, a FOV camera that automatically pans, and one that acts as a Pan-Tilt-Zoom camera with a locked range and of course your Cinemachine Brain. First we’ll look at the PTZ camera.
Next we’ll look at the Static camera. This is just a basic static camera staring down the Hall.
Finally the last camera is the FOV camera. This camera simply pans back and forth using the animation system as you can see below.
Lastly here is the code block that governs this entire scene. Commented for your convenience, simply add to the trigger in your scene and you should be ready to go.
As you can see this is a powerful component in Unity that provides a suite of tools to create and control virtual cameras in a scene. It provides the ability to blend multiple virtual cameras, add noise to the camera movement, and control the final output to the scene view. The Cinemachine Brain can be controlled through the Unity Editor or through scripts, providing a flexible and customizable solution for camera management in Unity. Until next time, happy coding.