Class CinemachineMixingCamera
CinemachineMixingCamera is a "manager camera" that takes on the state of the weighted average of the states of its child virtual cameras.
A fixed number of slots are made available for cameras, rather than a dynamic array. We do it this way in order to support weight animation from the Timeline. Timeline cannot animate array elements.
Inheritance
Inherited Members
Namespace: Cinemachine
Syntax
[DocumentationSorting(DocumentationSortingAttribute.Level.UserRef)]
[DisallowMultipleComponent]
[ExecuteAlways]
[ExcludeFromPreset]
[AddComponentMenu("Cinemachine/CinemachineMixingCamera")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.cinemachine@2.9/manual/CinemachineMixingCamera.html")]
public class CinemachineMixingCamera : CinemachineVirtualCameraBase, ICinemachineCamera, ISerializationCallbackReceiver
Fields
m_Weight0
Weight of the first tracked camera
Declaration
[Tooltip("The weight of the first tracked camera")]
public float m_Weight0
Field Value
Type | Description |
---|---|
Single |
m_Weight1
Weight of the second tracked camera
Declaration
[Tooltip("The weight of the second tracked camera")]
public float m_Weight1
Field Value
Type | Description |
---|---|
Single |
m_Weight2
Weight of the third tracked camera
Declaration
[Tooltip("The weight of the third tracked camera")]
public float m_Weight2
Field Value
Type | Description |
---|---|
Single |
m_Weight3
Weight of the fourth tracked camera
Declaration
[Tooltip("The weight of the fourth tracked camera")]
public float m_Weight3
Field Value
Type | Description |
---|---|
Single |
m_Weight4
Weight of the fifth tracked camera
Declaration
[Tooltip("The weight of the fifth tracked camera")]
public float m_Weight4
Field Value
Type | Description |
---|---|
Single |
m_Weight5
Weight of the sixth tracked camera
Declaration
[Tooltip("The weight of the sixth tracked camera")]
public float m_Weight5
Field Value
Type | Description |
---|---|
Single |
m_Weight6
Weight of the seventh tracked camera
Declaration
[Tooltip("The weight of the seventh tracked camera")]
public float m_Weight6
Field Value
Type | Description |
---|---|
Single |
m_Weight7
Weight of the eighth tracked camera
Declaration
[Tooltip("The weight of the eighth tracked camera")]
public float m_Weight7
Field Value
Type | Description |
---|---|
Single |
MaxCameras
The maximum number of tracked cameras. If you want to add more cameras, do it here in the source code, and be sure to add the extra member variables and to make the appropriate changes in GetWeight() and SetWeight(). The inspector will figure itself out based on this value.
Declaration
public const int MaxCameras = 8
Field Value
Type | Description |
---|---|
Int32 |
Properties
ChildCameras
Get the cached list of child cameras. These are just the immediate children in the hierarchy. Note: only the first entries of this list participate in the final blend, up to MaxCameras
Declaration
public CinemachineVirtualCameraBase[] ChildCameras { get; }
Property Value
Type | Description |
---|---|
CinemachineVirtualCameraBase[] |
Follow
Not used
Declaration
public override Transform Follow { get; set; }
Property Value
Type | Description |
---|---|
Transform |
Overrides
LookAt
Not used
Declaration
public override Transform LookAt { get; set; }
Property Value
Type | Description |
---|---|
Transform |
Overrides
State
The blended CameraState
Declaration
public override CameraState State { get; }
Property Value
Type | Description |
---|---|
CameraState |
Overrides
Methods
ForceCameraPosition(Vector3, Quaternion)
Force the virtual camera to assume a given position and orientation
Declaration
public override void ForceCameraPosition(Vector3 pos, Quaternion rot)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | pos | Worldspace pposition to take |
Quaternion | rot | Worldspace orientation to take |
Overrides
GetWeight(CinemachineVirtualCameraBase)
Get the weight of the child CinemachineVirtualCameraBase.
Declaration
public float GetWeight(CinemachineVirtualCameraBase vcam)
Parameters
Type | Name | Description |
---|---|---|
CinemachineVirtualCameraBase | vcam | The child camera. |
Returns
Type | Description |
---|---|
Single | The weight of the camera. Valid only if camera is active and enabled. |
GetWeight(Int32)
Get the weight of the child at an index.
Declaration
public float GetWeight(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The child index. Only immediate CinemachineVirtualCameraBase children are counted. |
Returns
Type | Description |
---|---|
Single | The weight of the camera. Valid only if camera is active and enabled. |
InternalUpdateCameraState(Vector3, Single)
Internal use only. Do not call this methid. Called by CinemachineCore at designated update time so the vcam can position itself and track its targets. This implementation computes and caches the weighted blend of the tracked cameras.
Declaration
public override void InternalUpdateCameraState(Vector3 worldUp, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | worldUp | Default world Up, set by the CinemachineBrain |
Single | deltaTime | Delta time for time-based effects (ignore if less than 0) |
Overrides
InvalidateListOfChildren()
Invalidate the cached list of child cameras.
Declaration
protected void InvalidateListOfChildren()
IsLiveChild(ICinemachineCamera, Boolean)
Check whether the vcam a live child of this camera.
Declaration
public override bool IsLiveChild(ICinemachineCamera vcam, bool dominantChildOnly = false)
Parameters
Type | Name | Description |
---|---|---|
ICinemachineCamera | vcam | The Virtual Camera to check |
Boolean | dominantChildOnly | If truw, will only return true if this vcam is the dominat live child |
Returns
Type | Description |
---|---|
Boolean | True if the vcam is currently actively influencing the state of this vcam |
Overrides
OnEnable()
Makes sure the internal child cache is up to date
Declaration
protected override void OnEnable()
Overrides
OnTargetObjectWarped(Transform, Vector3)
This is called to notify the vcam that a target got warped, so that the vcam can update its internal state to make the camera also warp seamlessy.
Declaration
public override void OnTargetObjectWarped(Transform target, Vector3 positionDelta)
Parameters
Type | Name | Description |
---|---|---|
Transform | target | The object that was warped |
Vector3 | positionDelta | The amount the target's position changed |
Overrides
OnTransformChildrenChanged()
Makes sure the internal child cache is up to date
Declaration
public void OnTransformChildrenChanged()
OnTransitionFromCamera(ICinemachineCamera, Vector3, Single)
Notification that this virtual camera is going live.
Declaration
public override void OnTransitionFromCamera(ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
ICinemachineCamera | fromCam | The camera being deactivated. May be null. |
Vector3 | worldUp | Default world Up, set by the CinemachineBrain |
Single | deltaTime | Delta time for time-based effects (ignore if less than or equal to 0) |
Overrides
OnValidate()
Makes sure the weights are non-negative
Declaration
protected override void OnValidate()
Overrides
SetWeight(CinemachineVirtualCameraBase, Single)
Set the weight of the child CinemachineVirtualCameraBase.
Declaration
public void SetWeight(CinemachineVirtualCameraBase vcam, float w)
Parameters
Type | Name | Description |
---|---|---|
CinemachineVirtualCameraBase | vcam | The child camera. |
Single | w | The weight to set. Can be any non-negative number. |
SetWeight(Int32, Single)
Set the weight of the child at an index.
Declaration
public void SetWeight(int index, float w)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The child index. Only immediate CinemachineVirtualCameraBase children are counted. |
Single | w | The weight to set. Can be any non-negative number. |
ValidateListOfChildren()
Rebuild the cached list of child cameras.
Declaration
protected void ValidateListOfChildren()