Class CinemachineBrain
CinemachineBrain is the link between the Unity Camera and the Cinemachine Virtual Cameras in the scene. It monitors the priority stack to choose the current Virtual Camera, and blend with another if necessary. Finally and most importantly, it applies the Virtual Camera state to the attached Unity Camera.
The CinemachineBrain is also the place where rules for blending between virtual cameras are defined. Camera blending is an interpolation over time of one virtual camera position and state to another. If you think of virtual cameras as cameramen, then blending is a little like one cameraman smoothly passing the camera to another cameraman. You can specify the time over which to blend, as well as the blend curve shape. Note that a camera cut is just a zero-time blend.
Inherited Members
Namespace: Unity.Cinemachine
Assembly: solution.dll
Syntax
[DisallowMultipleComponent]
[ExecuteAlways]
[AddComponentMenu("Cinemachine/Cinemachine Brain")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.cinemachine@3.0/manual/CinemachineBrain.html")]
public class CinemachineBrain : MonoBehaviour, ICameraOverrideStack, ICinemachineMixer, ICinemachineCamera
Fields
Name | Description |
---|---|
BlendUpdateMethod | The update time for the Brain, i.e. when the blends are evaluated and the brain's transform is updated. |
ChannelMask | The CinemachineBrain will find the highest-priority CinemachineCamera that outputs to any of the channels selected. CinemachineCameras that do not output to one of these channels will be ignored. Use this in situations where multiple CinemachineBrains are needed (for example, Split-screen). |
CustomBlends | This is the asset that contains custom settings for blends between specific virtual cameras in your scene. |
DefaultBlend | The blend which is used if you don't explicitly define a blend between two Virtual Cameras. |
IgnoreTimeScale | When enabled, the cameras will always respond in real-time to user input and damping, even if the game is running in slow motion |
LensModeOverride | Controls whether CM cameras can change the lens mode. |
ShowCameraFrustum | When enabled, shows the camera's frustum in the scene view. |
ShowDebugText | When enabled, the current camera and blend will be indicated in the game window, for debugging. |
UpdateMethod | Depending on how the target objects are animated, adjust the update method to minimize the potential jitter. Use FixedUpdate if all your targets are animated with for RigidBody animation. SmartUpdate will choose the best method for each virtual camera, depending on how the target is animated. |
WorldUpOverride | If set, this object's Y axis will define the world-space Up vector for all the virtual cameras. This is useful in top-down game environments. If not set, Up is world-space Y. |
Properties
Name | Description |
---|---|
ActiveBlend | Get the current blend in progress. Returns null if none. It is also possible to set the current blend, but this is not a recommended usage unless it is to set the active blend to null, which will force completion of the blend. |
ActiveBrainCount | Access the array of active CinemachineBrains in the scene |
ActiveVirtualCamera | Get the current active virtual camera. |
ControlledObject | CinemachineBrain controls this GameObject. Normally, this is the GameObject to which the CinemachineBrain component is attached. However, it is possible to override this by setting this property to another GameObject. If a Camera component is attached to the Controlled Object, then that Camera component's lens settings will also be driven by the CinemachineBrain. If this property is set to null, then CinemachineBrain is controlling the GameObject to which it is attached. The value of this property will always report as non-null. |
DefaultWorldUp | Get the default world up for the virtual cameras. |
Description | Gets a brief debug description of this camera, for use when displaying debug info |
IsBlending | Is there a blend in progress? |
IsValid | Will return false if this references a deleted object |
Name | Gets the name of this virtual camera. For use when deciding how to blend to or from this camera |
OutputCamera | Get the Unity Camera that is attached to this GameObject. This is the camera that will be controlled by the brain. |
ParentCamera | Returns the ICinemachineMixer within which this Camera is nested, or null. |
State | Camera state at the current time. |
Methods
Name | Description |
---|---|
GetActiveBrain(int) | Access the array of active CinemachineBrains in the scene without generating garbage |
IsLiveChild(ICinemachineCamera, bool) | Check whether the cam is a live child of this camera. |
IsLiveInBlend(ICinemachineCamera) | Checks if the vcam is live as part of an outgoing blend. |
IsValidChannel(CinemachineVirtualCameraBase) | Returns true if camera is on a channel that is handles by this Brain. |
ManualUpdate() | Call this method explicitly from an external script to update the virtual cameras and position the main camera, if the UpdateMode is set to ManualUpdate. For other update modes, this method is called automatically, and should not be called from elsewhere. |
OnCameraActivated(ActivationEventParams) | Notification that this camera is being activated. This is sent to the newly activated camera. |
ReleaseCameraOverride(int) | See SetCameraOverride. Call ReleaseCameraOverride after all overriding is finished, to free the OverrideStack resources. |
ResetState() | Call this to reset the current active camera, causing the brain to choose a new one without blending. It is useful, for example, when you want to restart a game level. |
SetCameraOverride(int, int, ICinemachineCamera, ICinemachineCamera, float, float) | Override the current camera and current blend. This setting will trump any in-game logic that sets virtual camera priorities and Enabled states. This is the main API for the timeline. |
TopCameraFromPriorityQueue() | Choose the default active camera in the case that there is no camera override. |
UpdateCameraState(Vector3, float) | Update the camera's state. The implementation must guarantee against multiple calls per frame, and should use CinemachineCore.UpdateVirtualCamera(ICinemachineCamera, Vector3, float), which has protection against multiple calls per frame. |