Class CinemachineAutoFocus
This behaviour will drive the Camera focusDistance property. It can be used to hold focus onto a specific object, or (in HDRP) to auto-detect what is in front of the camera and focus on that.
Camera.focusDistance is only available in physical mode, and appropriate processing must be installed for it to have any visible effect.
This component's ScreenCenter mode is only available in HDRP projects, and in this mode the component cannot be dynamically added at runtime; it must be added in the editor.
Inheritance
Inherited Members
Namespace: Unity.Cinemachine
Assembly: Unity.Cinemachine.dll
Syntax
[ExecuteAlways]
[AddComponentMenu("Cinemachine/Procedural/Extensions/Cinemachine Auto Focus")]
[DisallowMultipleComponent]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.cinemachine@3.1/manual/CinemachineAutoFocus.html")]
public class CinemachineAutoFocus : CinemachineExtension
Fields
CustomTarget
The target to use if Focus Target is set to Custom Target
Declaration
[Tooltip("The target to use if Focus Target is set to Custom Target")]
public Transform CustomTarget
Field Value
Type | Description |
---|---|
Transform |
Damping
Set this to make the focus adjust gradually to the desired setting. The value corresponds approximately to the time the focus will take to adjust to the new value.
Declaration
[Tooltip("The value corresponds approximately to the time the focus will take to adjust to the new value.")]
public float Damping
Field Value
Type | Description |
---|---|
float |
FocusDepthOffset
Offsets the sharpest point away in depth from the focus target location
Declaration
[Tooltip("Offsets the sharpest point away in depth from the focus target location.")]
public float FocusDepthOffset
Field Value
Type | Description |
---|---|
float |
FocusTarget
The camera's focus distance will be set to the distance from the camera to the selected target. The Focus Offset field will then modify that distance.
Declaration
[Tooltip("The camera's focus distance will be set to the distance from the camera to the selected target. The Focus Offset field will then modify that distance.")]
public CinemachineAutoFocus.FocusTrackingMode FocusTarget
Field Value
Type | Description |
---|---|
CinemachineAutoFocus.FocusTrackingMode |
Methods
PostPipelineStageCallback(CinemachineVirtualCameraBase, Stage, ref CameraState, float)
Apply PostProcessing effects
Declaration
protected override void PostPipelineStageCallback(CinemachineVirtualCameraBase vcam, CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
CinemachineVirtualCameraBase | vcam | The virtual camera being processed |
CinemachineCore.Stage | stage | The current pipeline stage |
CameraState | state | The current virtual camera state |
float | deltaTime | The current applicable deltaTime |