Class CinemachineStateDrivenCamera
This is a virtual camera "manager" that owns and manages a collection of child Virtual Cameras. These child vcams are mapped to individual states in an animation state machine, allowing you to associate specific vcams to specific animation states. When that state is active in the state machine, then the associated camera will be activated.
You can define custom blends and transitions between child cameras.
In order to use this behaviour, you must have an animated target (i.e. an object animated with a state machine) to drive the behaviour.
Inheritance
Inherited Members
Namespace: Unity.Cinemachine
Assembly: Unity.Cinemachine.dll
Syntax
[DisallowMultipleComponent]
[ExecuteAlways]
[ExcludeFromPreset]
[AddComponentMenu("Cinemachine/Cinemachine State Driven Camera")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.cinemachine@3.1/manual/CinemachineStateDrivenCamera.html")]
public class CinemachineStateDrivenCamera : CinemachineCameraManagerBase, ICinemachineMixer, ICinemachineCamera
Fields
AnimatedTarget
The state machine whose state changes will drive this camera's choice of active child
Declaration
[Space]
[Tooltip("The state machine whose state changes will drive this camera's choice of active child")]
[FormerlySerializedAs("m_AnimatedTarget")]
public Animator AnimatedTarget
Field Value
Type | Description |
---|---|
Animator |
Instructions
The set of instructions associating virtual cameras with states. These instructions are used to choose the live child at any given moment
Declaration
[Tooltip("The set of instructions associating cameras with states. These instructions are used to choose the live child at any given moment")]
[FormerlySerializedAs("m_Instructions")]
public CinemachineStateDrivenCamera.Instruction[] Instructions
Field Value
Type | Description |
---|---|
Instruction[] |
LayerIndex
Which layer in the target FSM to observe
Declaration
[Tooltip("Which layer in the target state machine to observe")]
[FormerlySerializedAs("m_LayerIndex")]
public int LayerIndex
Field Value
Type | Description |
---|---|
int |
Methods
CancelWait()
Call this to cancel the current wait time for the pending instruction and activate the pending instruction immediately.
Declaration
public void CancelWait()
ChooseCurrentCamera(Vector3, float)
Choose the appropriate current camera from among the ChildCameras, based on current state. If the returned camera is different from the current camera, an appropriate transition will be made.
Declaration
protected override CinemachineVirtualCameraBase ChooseCurrentCamera(Vector3 worldUp, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | worldUp | Default world Up, set by the CinemachineBrain |
float | deltaTime | Delta time for time-based effects (ignore if less than or equal to 0) |
Returns
Type | Description |
---|---|
CinemachineVirtualCameraBase | The current child camera that should be active. Must be present in ChildCameras. |
Overrides
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.
Declaration
protected override void PerformLegacyUpgrade(int streamedVersion)
Parameters
Type | Name | Description |
---|---|---|
int | streamedVersion | The version that was streamed |
Overrides
Reset()
Reset the component to default values.
Declaration
protected override void Reset()