Class CinemachineVirtualCameraBase
Base class for a Monobehaviour that represents a Virtual Camera within the Unity scene.
This is intended to be attached to an empty Transform GameObject. Inherited classes can be either standalone virtual cameras such as CinemachineCamera, or meta-cameras such as CinemachineClearShot or CinemachineBlendListCamera.
A CinemachineVirtualCameraBase exposes an OutputChannel property. When the behaviour is enabled in the game, the Virtual Camera is automatically placed in a queue maintained by the static CinemachineCore singleton. The queue is sorted by priority. When a Unity camera is equipped with a CinemachineBrain behaviour, the brain will choose the camera at the head of the queue. If you have multiple Unity cameras with CinemachineBrain behaviours (say in a split-screen context), then you can filter the queue by setting the culling flags on the virtual cameras. The culling mask of the Unity Camera will then act as a filter for the brain. Apart from this, there is nothing that prevents a virtual camera from controlling multiple Unity cameras simultaneously.
Implements
Inherited Members
Namespace: Unity.Cinemachine
Assembly: solution.dll
Syntax
public abstract class CinemachineVirtualCameraBase : MonoBehaviour, ICinemachineCamera
Fields
Name | Description |
---|---|
FollowTargetAttachment | This must be set every frame at the start of the pipeline to relax the virtual camera's
attachment to the target. Range is 0...1. |
LookAtTargetAttachment | This must be set every frame at the start of the pipeline to relax the virtual camera's
attachment to the target. Range is 0...1. |
OutputChannel | The output channel functions like Unity layers. Use it to filter the output of CinemachineCameras to different CinemachineBrains, for instance in a multi-screen environemnt. |
Priority | Priority can be used to control which Cm Camera is live when multiple CM Cameras are active simultaneously. The most-recently-activated CinemachineCamera will take control, unless there is another Cm Camera active with a higher priority. In general, the most-recently-activated highest-priority CinemachineCamera will control the main camera.
|
StandbyUpdate | When the virtual camera is not live, this is how often the virtual camera will be updated. Set this to tune for performance. Most of the time Never is fine, unless the virtual camera is doing shot evaluation. |
Properties
Name | Description |
---|---|
Description | Gets a brief debug description of this virtual camera, for use when displaying debug info |
Follow | Get the Follow target for the Body component in the Cinemachine pipeline. |
FollowTargetAsGroup | Get Follow target as ICinemachineTargetGroup, or null if target is not a ICinemachineTargetGroup |
FollowTargetAsVcam | Get Follow target as CinemachineVirtualCameraBase, or null if target is not a CinemachineVirtualCameraBase |
FollowTargetChanged | This property is true if the Follow target was changed this frame. |
IsDprecated | Helper for upgrading from CM2 |
IsLive | Returns true if this camera is currently live for some CinemachineBrain. |
IsValid | Returns false if the object has been deleted |
LookAt | Get the LookAt target for the Aim component in the Cinemachine pipeline. |
LookAtTargetAsGroup | Get LookAt target as ICinemachineTargetGroup, or null if target is not a ICinemachineTargetGroup |
LookAtTargetAsVcam | Get LookAt target as CinemachineVirtualCameraBase, or null if target is not a CinemachineVirtualCameraBase |
LookAtTargetChanged | This property is true if the LookAtTarget was changed this frame. |
Name | Get the name of the Virtual Camera. Base implementation returns a cache of the owner GameObject's name. |
ParentCamera | 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. |
PreviousStateIsValid | Set this to force the next update to ignore state from the previous frame. |
State | The CameraState object holds all of the information necessary to position the Unity camera. It is the output of this class. |
Methods
Name | Description |
---|---|
CancelDamping(bool) | Temporarily cancel damping for this frame. The camera will sanp to its target position when it is updated. |
DetachedFollowTargetDamp(float, float, float) | Get a damped version of a quantity. This is the portion of the quantity that will take effect over the given time. This method takes the target attachment into account. For general damping without consideration of target attachment, use Damper.Damp() |
DetachedFollowTargetDamp(Vector3, float, float) | Get a damped version of a quantity. This is the portion of the quantity that will take effect over the given time. This method takes the target attachment into account. For general damping without consideration of target attachment, use Damper.Damp() |
DetachedFollowTargetDamp(Vector3, Vector3, float) | Get a damped version of a quantity. This is the portion of the quantity that will take effect over the given time. This method takes the target attachment into account. For general damping without consideration of target attachment, use Damper.Damp() |
DetachedLookAtTargetDamp(float, float, float) | Get a damped version of a quantity. This is the portion of the quantity that will take effect over the given time. This method takes the target attachment into account. For general damping without consideration of target attachment, use Damper.Damp() |
DetachedLookAtTargetDamp(Vector3, float, float) | Get a damped version of a quantity. This is the portion of the quantity that will take effect over the given time. This method takes the target attachment into account. For general damping without consideration of target attachment, use Damper.Damp() |
DetachedLookAtTargetDamp(Vector3, Vector3, float) | Get a damped version of a quantity. This is the portion of the quantity that will take effect over the given time. This method takes the target attachment into account. For general damping without consideration of target attachment, use Damper.Damp() |
ForceCameraPosition(Vector3, Quaternion) | Force the virtual camera to assume a given position and orientation |
GetCinemachineComponent(Stage) | Get the component set for a specific stage in the pipeline. |
GetMaxDampTime() | Query components and extensions for the maximum damping time. Base class implementation queries extensions. Only used in editor for timeline scrubbing. |
InternalUpdateCameraState(Vector3, float) | Internal use only. |
InvokeOnTransitionInExtensions(ICinemachineCamera, Vector3, float) | Invokes the OnTransitionFromCamera for all extensions on this camera |
InvokePostPipelineStageCallback(CinemachineVirtualCameraBase, Stage, ref CameraState, float) | Invokes the PostPipelineStageDelegate for this camera, and up the hierarchy for all parent cameras (if any). Implementation must be sure to call this after each pipeline stage, to allow other services to hook into the pipeline. See CinemachineCore.Stage. |
InvokePrePipelineMutateCameraStateCallback(CinemachineVirtualCameraBase, ref CameraState, float) | Invokes the PrePipelineMutateCameraStateCallback for this camera, and up the hierarchy for all parent cameras (if any). Implementation must be sure to call this after each pipeline stage, to allow other services to hook into the pipeline. See CinemachineCore.Stage. |
IsParticipatingInBlend() | Check to see whether this camera is currently participating in a blend within its parent manager or in a CinemacineBrain |
MoveToTopOfPrioritySubqueue() | 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.
|
OnCameraActivated(ActivationEventParams) | Notification that this camera is being activated. This is sent to the newly activated camera. |
OnDestroy() | Maintains the global vcam registry. Always call the base class implementation. |
OnDisable() | Base class implementation makes sure the priority queue remains up-to-date. |
OnEnable() | Base class implementation adds the virtual camera from the priority queue. |
OnTargetObjectWarped(Transform, Vector3) | This is called to notify the component that a target got warped, so that the component can update its internal state to make the camera also warp seamlessly. |
OnTransformParentChanged() | Base class implementation makes sure the priority queue remains up-to-date. |
OnTransitionFromCamera(ICinemachineCamera, Vector3, float) | Notification that this virtual camera is going live. Base class implementation must be called by any overridden method. |
PerformLegacyUpgrade(int) | Override this to handle any upgrades necessitated by a streaming version change. Note that since this method is not called from the main thread, there are many things it cannot do, including checking a unity object for null. |
Prioritize() | When multiple Cm 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.
|
PullStateFromVirtualCamera(Vector3, ref LensSettings) | Create a camera state based on the current transform of this vcam |
ResolveFollow(Transform) | Returns this vcam's Follow target, or if that is null, will retrun the parent vcam's Follow target. |
ResolveLookAt(Transform) | Returns this vcam's LookAt target, or if that is null, will return the parent vcam's LookAt target. |
Start() | Derived classes should call base class implementation. |
Update() | Base class implementation makes sure the priority queue remains up-to-date. |
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. |
UpdateTargetCache() | Call this from InternalUpdateCameraState() to check for changed targets and update the target cache. This is needed for tracking when a target object changes. |