Class CinemachineCollider | Cinemachine | 2.5.0
docs.unity3d.com
    Show / Hide Table of Contents

    Class CinemachineCollider

    An add-on module for Cinemachine Virtual Camera that post-processes the final position of the virtual camera. Based on the supplied settings, the Collider will attempt to preserve the line of sight with the LookAt target of the virtual camera by moving away from objects that will obstruct the view.

    Additionally, the Collider can be used to assess the shot quality and report this as a field in the camera State.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    CinemachineExtension
    CinemachineCollider
    Inherited Members
    CinemachineExtension.Epsilon
    CinemachineExtension.VirtualCamera
    CinemachineExtension.Awake()
    CinemachineExtension.ConnectToVcam(Boolean)
    CinemachineExtension.InvokePostPipelineStageCallback(CinemachineVirtualCameraBase, CinemachineCore.Stage, CameraState, Single)
    CinemachineExtension.OnTargetObjectWarped(Transform, Vector3)
    CinemachineExtension.OnTransitionFromCamera(ICinemachineCamera, Vector3, Single)
    CinemachineExtension.GetExtraState<T>(ICinemachineCamera)
    CinemachineExtension.GetAllExtraStates<T>()
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(String, Single)
    MonoBehaviour.InvokeRepeating(String, Single, Single)
    MonoBehaviour.CancelInvoke(String)
    MonoBehaviour.IsInvoking(String)
    MonoBehaviour.StartCoroutine(String)
    MonoBehaviour.StartCoroutine(String, Object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(String)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(Object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, Component)
    Component.TryGetComponent<T>(T)
    Component.GetComponent(String)
    Component.GetComponentInChildren(Type, Boolean)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(Boolean)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, Boolean)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(Boolean)
    Component.GetComponentsInChildren<T>(Boolean, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, Boolean)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(Boolean)
    Component.GetComponentsInParent<T>(Boolean, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(String)
    Component.SendMessageUpwards(String, Object, SendMessageOptions)
    Component.SendMessageUpwards(String, Object)
    Component.SendMessageUpwards(String)
    Component.SendMessageUpwards(String, SendMessageOptions)
    Component.SendMessage(String, Object)
    Component.SendMessage(String)
    Component.SendMessage(String, Object, SendMessageOptions)
    Component.SendMessage(String, SendMessageOptions)
    Component.BroadcastMessage(String, Object, SendMessageOptions)
    Component.BroadcastMessage(String, Object)
    Component.BroadcastMessage(String)
    Component.BroadcastMessage(String, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Component.rigidbody
    Component.rigidbody2D
    Component.camera
    Component.light
    Component.animation
    Component.constantForce
    Component.renderer
    Component.audio
    Component.networkView
    Component.collider
    Component.collider2D
    Component.hingeJoint
    Component.particleSystem
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, Boolean)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, Single)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
    Object.FindObjectOfType<T>()
    UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindObjectOfType(Type, Boolean)
    Object.ToString()
    Object.name
    Object.hideFlags
    Namespace: Cinemachine
    Syntax
    [DocumentationSorting(DocumentationSortingAttribute.Level.UserRef)]
    [AddComponentMenu("")]
    [ExecuteInEditMode]
    public class CinemachineCollider : CinemachineExtension

    Fields

    m_AvoidObstacles

    When enabled, will attempt to resolve situations where the line of sight to the target is blocked by an obstacle

    Declaration
    [Space]
    [Tooltip("When enabled, will attempt to resolve situations where the line of sight to the target is blocked by an obstacle")]
    [FormerlySerializedAs("m_PreserveLineOfSight")]
    public bool m_AvoidObstacles
    Field Value
    Type Description
    Boolean

    m_CameraRadius

    Camera will try to maintain this distance from any obstacle. Increase this value if you are seeing inside obstacles due to a large FOV on the camera.

    Declaration
    [Tooltip("Camera will try to maintain this distance from any obstacle.  Try to keep this value small.  Increase it if you are seeing inside obstacles due to a large FOV on the camera.")]
    public float m_CameraRadius
    Field Value
    Type Description
    Single

    m_CollideAgainst

    Objects on these layers will be detected.

    Declaration
    [Header("Obstacle Detection")]
    [Tooltip("Objects on these layers will be detected")]
    public LayerMask m_CollideAgainst
    Field Value
    Type Description
    LayerMask

    m_Damping

    How gradually the camera returns to its normal position after having been corrected. Higher numbers will move the camera more gradually back to normal.

    Declaration
    [Range(0F, 10F)]
    [Tooltip("How gradually the camera returns to its normal position after having been corrected.  Higher numbers will move the camera more gradually back to normal.")]
    [FormerlySerializedAs("m_Smoothing")]
    public float m_Damping
    Field Value
    Type Description
    Single

    m_DampingWhenOccluded

    How gradually the camera moves to resolve an occlusion. Higher numbers will move the camera more gradually.

    Declaration
    [Range(0F, 10F)]
    [Tooltip("How gradually the camera moves to resolve an occlusion.  Higher numbers will move the camera more gradually.")]
    public float m_DampingWhenOccluded
    Field Value
    Type Description
    Single

    m_DistanceLimit

    The raycast distance to test for when checking if the line of sight to this camera's target is clear.

    Declaration
    [Tooltip("The maximum raycast distance when checking if the line of sight to this camera's target is clear.  If the setting is 0 or less, the current actual distance to target will be used.")]
    [FormerlySerializedAs("m_LineOfSightFeelerDistance")]
    public float m_DistanceLimit
    Field Value
    Type Description
    Single

    m_IgnoreTag

    Obstacles with this tag will be ignored. It is a good idea to set this field to the target's tag

    Declaration
    [Tooltip("Obstacles with this tag will be ignored.  It is a good idea to set this field to the target's tag")]
    public string m_IgnoreTag
    Field Value
    Type Description
    String

    m_MaximumEffort

    Upper limit on how many obstacle hits to process. Higher numbers may impact performance. In most environments, 4 is enough.

    Declaration
    [Range(1F, 10F)]
    [Tooltip("Upper limit on how many obstacle hits to process.  Higher numbers may impact performance.  In most environments, 4 is enough.")]
    public int m_MaximumEffort
    Field Value
    Type Description
    Int32

    m_MinimumDistanceFromTarget

    Obstacles closer to the target than this will be ignored

    Declaration
    [Tooltip("Obstacles closer to the target than this will be ignored")]
    public float m_MinimumDistanceFromTarget
    Field Value
    Type Description
    Single

    m_MinimumOcclusionTime

    Don't take action unless occlusion has lasted at least this long.

    Declaration
    [Tooltip("Don't take action unless occlusion has lasted at least this long.")]
    public float m_MinimumOcclusionTime
    Field Value
    Type Description
    Single

    m_OptimalTargetDistance

    If greater than zero, a higher score will be given to shots when the target is closer to this distance. Set this to zero to disable this feature

    Declaration
    [Header("Shot Evaluation")]
    [Tooltip("If greater than zero, a higher score will be given to shots when the target is closer to this distance.  Set this to zero to disable this feature.")]
    public float m_OptimalTargetDistance
    Field Value
    Type Description
    Single

    m_SmoothingTime

    Smoothing to apply to obstruction resolution. Nearest camera point is held for at least this long.

    Declaration
    [Range(0F, 2F)]
    [Tooltip("Smoothing to apply to obstruction resolution.  Nearest camera point is held for at least this long")]
    public float m_SmoothingTime
    Field Value
    Type Description
    Single

    m_Strategy

    The way in which the Collider will attempt to preserve sight of the target.

    Declaration
    [Tooltip("The way in which the Collider will attempt to preserve sight of the target.")]
    public CinemachineCollider.ResolutionStrategy m_Strategy
    Field Value
    Type Description
    CinemachineCollider.ResolutionStrategy

    m_TransparentLayers

    Objects on these layers will never obstruct view of the target.

    Declaration
    [Tooltip("Objects on these layers will never obstruct view of the target")]
    public LayerMask m_TransparentLayers
    Field Value
    Type Description
    LayerMask

    Properties

    DebugPaths

    Inspector API for debugging collision resolution path

    Declaration
    public List<List<Vector3>> DebugPaths { get; }
    Property Value
    Type Description
    List<List<Vector3>>

    Methods

    CameraWasDisplaced(ICinemachineCamera)

    See whether the virtual camera has been moved nby the collider

    Declaration
    public bool CameraWasDisplaced(ICinemachineCamera vcam)
    Parameters
    Type Name Description
    ICinemachineCamera vcam

    The virtual camera in question. This might be different from the virtual camera that owns the collider, in the event that the camera has children

    Returns
    Type Description
    Boolean

    True if the virtual camera has been displaced due to collision or target obstruction

    IsTargetObscured(ICinemachineCamera)

    See wheter an object is blocking the camera's view of the target

    Declaration
    public bool IsTargetObscured(ICinemachineCamera vcam)
    Parameters
    Type Name Description
    ICinemachineCamera vcam

    The virtual camera in question. This might be different from the virtual camera that owns the collider, in the event that the camera has children

    Returns
    Type Description
    Boolean

    True if something is blocking the view

    OnDestroy()

    Declaration
    protected override void OnDestroy()
    Overrides
    CinemachineExtension.OnDestroy()

    PostPipelineStageCallback(CinemachineVirtualCameraBase, CinemachineCore.Stage, ref CameraState, Single)

    Callback to do the collision resolution and shot evaluation

    Declaration
    protected override void PostPipelineStageCallback(CinemachineVirtualCameraBase vcam, CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
    Parameters
    Type Name Description
    CinemachineVirtualCameraBase vcam
    CinemachineCore.Stage stage
    CameraState state
    Single deltaTime
    Overrides
    CinemachineExtension.PostPipelineStageCallback(CinemachineVirtualCameraBase, CinemachineCore.Stage, ref CameraState, Single)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023