CinemachineVirtualCamera Class

Cinemachine

CinemachineVirtualCamera Class

This behaviour is intended to be attached to an empty Transform GameObject, and it represents a Virtual Camera within the Unity scene. The Virtual Camera will animate its Transform according to the rules contained in its CinemachineComponent pipeline (Aim, Body, and Noise). When the virtual camera is Live, the Unity camera will assume the position and orientation of the virtual camera. A virtual camera is not a camera. Instead, it can be thought of as a camera controller, not unlike a cameraman. It can drive the Unity Camera and control its position, orientation, lens settings, and PostProcessing effects. Each Virtual Camera owns its own Cinemachine Component Pipeline, through which you provide the instructions for dynamically tracking specific game objects. A virtual camera is very lightweight, and does no rendering of its own. It merely tracks interesting GameObjects, and positions itself accordingly. A typical game can have dozens of virtual cameras, each set up to follow a particular character or capture a particular event. A Virtual Camera can be in any of three states: * **Live**: The virtual camera is actively controlling the Unity Camera. The virtual camera is tracking its targets and being updated every frame. * **Standby**: The virtual camera is tracking its targets and being updated every frame, but no Unity Camera is actively being controlled by it. This is the state of a virtual camera that is enabled in the scene but perhaps at a lower priority than the Live virtual camera. * **Disabled**: The virtual camera is present but disabled in the scene. It is not actively tracking its targets and so consumes no processing power. However, the virtual camera can be made live from the Timeline. The Unity Camera can be driven by any virtual camera in the scene. The game logic can choose the virtual camera to make live by manipulating the virtual cameras' enabled flags and their priorities, based on game logic. In order to be driven by a virtual camera, the Unity Camera must have a CinemachineBrain behaviour, which will select the most eligible virtual camera based on its priority or on other criteria, and will manage blending.
Inheritance Hierarchy
SystemObject  Object
    Component
      Behaviour
        MonoBehaviour
          CinemachineCinemachineVirtualCameraBase
            CinemachineCinemachineVirtualCamera

Namespace:  Cinemachine
Assembly:  Cinemachine (in Cinemachine.dll) Version: 2.0.0.0 (2.0.0.0)
Syntax
[DocumentationSortingAttribute(1f, DocumentationSortingAttributeLevel.UserRef)]
[ExecuteInEditMode]
[DisallowMultipleComponent]
[AddComponentMenu("Cinemachine/CinemachineVirtualCamera")]
public class CinemachineVirtualCamera : CinemachineVirtualCameraBase
Cinemachine.CinemachineVirtualCamera = function();

Type.createClass(
	'Cinemachine.CinemachineVirtualCamera',
	Cinemachine.CinemachineVirtualCameraBase);

The CinemachineVirtualCamera type exposes the following members.

Constructors
  NameDescription
Public methodCinemachineVirtualCamera
Top
Properties
  NameDescription
Public propertyDescription
Gets a brief debug description of this virtual camera, for use when displayiong debug info
(Inherited from CinemachineVirtualCameraBase.)
Public propertyFollow
Get the Follow target for the Body component in the CinemachinePipeline. If this vcam is a part of a meta-camera collection, then the owner's target will be used if the local target is null.
(Overrides CinemachineVirtualCameraBaseFollow.)
Public propertyLiveChildOrSelf
Just returns self.
(Inherited from CinemachineVirtualCameraBase.)
Public propertyLookAt
Get the LookAt target for the Aim component in the CinemachinePipeline. If this vcam is a part of a meta-camera collection, then the owner's target will be used if the local target is null.
(Overrides CinemachineVirtualCameraBaseLookAt.)
Public propertyName
Get the name of the Virtual Camera. Base implementation returns the owner GameObject's name.
(Inherited from CinemachineVirtualCameraBase.)
Public propertyParentCamera
Support for meta-virtual-cameras. This is the situation where a virtual camera is in fact the public face of a private army of virtual cameras, which it manages on its own. This method gets the VirtualCamera owner, if any. Private armies are implemented as Transform children of the parent vcam.
(Inherited from CinemachineVirtualCameraBase.)
Public propertyPreviousStateIsValid
Set this to force the next update to ignore deltaTime and reset itself
(Inherited from CinemachineVirtualCameraBase.)
Public propertyPriority
Get the Priority of the virtual camera. This determines its placement in the CinemachineCore's queue of eligible shots.
(Inherited from CinemachineVirtualCameraBase.)
Public propertyState
The CameraState object holds all of the information necessary to position the Unity camera. It is the output of this class.
(Overrides CinemachineVirtualCameraBaseState.)
Public propertyUserIsDragging
API for the editor, to make the dragging of position handles behave better.
Public propertyValidatingStreamVersion
Version that was last streamed, for upgrading legacy
(Inherited from CinemachineVirtualCameraBase.)
Public propertyVirtualCameraGameObject
The GameObject owner of the Virtual Camera behaviour.
(Inherited from CinemachineVirtualCameraBase.)
Top
Methods
  NameDescription
Public methodAddCinemachineComponentT
Add a component to the cinemachine pipeline.
Public methodAddPostPipelineStageHook
A delegate to hook into the state calculation pipeline. This will be called after each pipeline stage, to allow others to hook into the pipeline. See CinemachineCore.Stage.
(Inherited from CinemachineVirtualCameraBase.)
Public methodDestroyCinemachineComponentT
Remove a component from the cinemachine pipeline.
Public methodGetCinemachineComponent(CinemachineCoreStage)
Get the component set for a specific stage.
Public methodGetCinemachineComponentT
Get an existing component of a specific type from the cinemachine pipeline.
Public methodGetComponentOwner
Get the hidden CinemachinePipeline child object.
Public methodGetComponentPipeline
Get the component pipeline owned by the hidden child pipline container. For most purposes, it is preferable to use the GetCinemachineComponent method.
Public methodInvalidateComponentPipeline
Editor API: Call this when changing the pipeline from the editor. Will force a rebuild of the pipeline cache.
Protected methodInvokePostPipelineStageCallback
Invokes the PostPipelineStageDelegate for this camera, and up the hierarchy for all parent cameras (if any).
(Inherited from CinemachineVirtualCameraBase.)
Public methodIsLiveChild
Check whether the vcam a live child of this camera. This base class implementation always returns false.
(Inherited from CinemachineVirtualCameraBase.)
Public methodMoveToTopOfPrioritySubqueue
When multiple virtual cameras have the highest priority, there is sometimes the need to push one to the top, making it the current Live camera if it shares the highest priority in the queue with its peers. This happens automatically when a new vcam is enabled: the most recent one goes to the top of the priority subqueue. Use this method to push a vcam to the top of its priority peers. If it and its peers share the highest priority, then this vcam will become Live.
(Inherited from CinemachineVirtualCameraBase.)
Protected methodOnDestroy
Calls the DestroyPipelineDelegate for destroying the hidden child object, to support undo.
(Overrides CinemachineVirtualCameraBaseOnDestroy.)
Protected methodOnDisable
Base class implementation makes sure the priority queue remains up-to-date.
(Inherited from CinemachineVirtualCameraBase.)
Protected methodOnEnable
Make sure that the pipeline cache is up-to-date.
(Overrides CinemachineVirtualCameraBaseOnEnable.)
Public methodOnPositionDragged
API for the editor, to process a position drag from the user.
Protected methodOnTransformParentChanged
Base class implementation makes sure the priority queue remains up-to-date.
(Inherited from CinemachineVirtualCameraBase.)
Public methodOnTransitionFromCamera
Notification that this virtual camera is going live. Base class implementationmust be called by any overridden method.
(Inherited from CinemachineVirtualCameraBase.)
Protected methodOnValidate
Enforce bounds for fields, when changed in inspector.
(Overrides CinemachineVirtualCameraBaseOnValidate.)
Public methodPreUpdateChildCameras
This is called prior to the updating of the vcam's child cameras, in order to allow the parent to prepare its children. If the children are updating on FixedUpdate, then this will not necessarily be called prior to every FixedUpdate, but it might be called on LateUpdate instead. Base class implementation does nothing.
(Inherited from CinemachineVirtualCameraBase.)
Public methodRemovePostPipelineStageHook
Remove a Pipeline stage hook callback.
(Inherited from CinemachineVirtualCameraBase.)
Protected methodResolveFollow
Returns this vcam's Follow target, or if that is null, will retrun the parent vcam's Follow target.
(Inherited from CinemachineVirtualCameraBase.)
Protected methodResolveLookAt
Returns this vcam's LookAt target, or if that is null, will retrun the parent vcam's LookAt target.
(Inherited from CinemachineVirtualCameraBase.)
Protected methodStart
Base class implementation does nothing.
(Inherited from CinemachineVirtualCameraBase.)
Protected methodUpdate
Base class implementation makes sure the priority queue remains up-to-date.
(Inherited from CinemachineVirtualCameraBase.)
Public methodUpdateCameraState
Called by CinemachineCore at LateUpdate time so the vcam can position itself and track its targets. This class will invoke its pipeline and generate a CameraState for this frame.
(Overrides CinemachineVirtualCameraBaseUpdateCameraState(Vector3, Single).)
Top
Fields
  NameDescription
Public fieldCinemachineGUIDebuggerCallback
This is deprecated. It is here to support the soon-to-be-removed Cinemachine Debugger in the Editor.
(Inherited from CinemachineVirtualCameraBase.)
Public fieldStatic memberCreatePipelineOverride
Override component pipeline creation. This needs to be done by the editor to support Undo. The override must do exactly the same thing as the CreatePipeline method in this class.
Public fieldStatic memberDestroyPipelineOverride
Override component pipeline destruction. This needs to be done by the editor to support Undo.
Public fieldm_ExcludedPropertiesInInspector
Inspector control - Use for hiding sections of the Inspector UI.
(Inherited from CinemachineVirtualCameraBase.)
Public fieldm_Follow
The object that the camera wants to move with (the Body target). The Body component of the CinemachineComponent pipeline will refer to this target and position the vcam in accordance with rules and settings that are provided to it. If this is null, then the vcam's Transform position will be used.
Public fieldm_Lens
Specifies the LensSettings of this Virtual Camera. These settings will be transferred to the Unity camera when the vcam is live.
Public fieldm_LockStageInInspector
Inspector control - Use for enabling sections of the Inspector UI.
(Inherited from CinemachineVirtualCameraBase.)
Public fieldm_LookAt
The object that the camera wants to look at (the Aim target). The Aim component of the CinemachineComponent pipeline will refer to this target and orient the vcam in accordance with rules and settings that are provided to it. If this is null, then the vcam's Transform orientation will be used.
Public fieldm_Priority
The priority will determine which camera becomes active based on the state of other cameras and this camera. Higher numbers have greater priority.
(Inherited from CinemachineVirtualCameraBase.)
Protected fieldOnPostPipelineStage
A delegate to hook into the state calculation pipeline. Implementaion must be sure to call this after each pipeline stage, to allow other services to hook into the pipeline. See CinemachineCore.Stage.
(Inherited from CinemachineVirtualCameraBase.)
Public fieldStatic memberPipelineName
This is the name of the hidden GameObject that will be created as a child object of the virtual camera. This hidden game object acts as a container for the polymorphic CinemachineComponent pipeline. The Inspector UI for the Virtual Camera provides access to this pipleline, as do the CinemachineComponent-family of public methods in this class. The lifecycle of the pipeline GameObject is managed automatically.
Top
See Also