Class CinemachineCollider | Package Manager UI website
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
    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.GetExtraState<T>(ICinemachineCamera)
    CinemachineExtension.GetAllExtraStates<T>()
    Namespace: Cinemachine
    Syntax
    [DocumentationSorting(DocumentationSortingAttribute.Level.UserRef)]
    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
    public bool m_AvoidObstacles
    Field Value
    Type Description
    System.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
    public float m_CameraRadius
    Field Value
    Type Description
    System.Single

    m_CollideAgainst

    The Unity layer mask against which the collider will raycast.

    Declaration
    public LayerMask m_CollideAgainst
    Field Value
    Type Description
    LayerMask

    m_Damping

    The gradualness of collision resolution. Higher numbers will move the camera more gradually away from obstructions.

    Declaration
    public float m_Damping
    Field Value
    Type Description
    System.Single

    m_DistanceLimit

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

    Declaration
    public float m_DistanceLimit
    Field Value
    Type Description
    System.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
    public string m_IgnoreTag
    Field Value
    Type Description
    System.String

    m_MaximumEffort

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

    Declaration
    public int m_MaximumEffort
    Field Value
    Type Description
    System.Int32

    m_MinimumDistanceFromTarget

    Obstacles closer to the target than this will be ignored

    Declaration
    public float m_MinimumDistanceFromTarget
    Field Value
    Type Description
    System.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
    public float m_OptimalTargetDistance
    Field Value
    Type Description
    System.Single

    m_Strategy

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

    Declaration
    public CinemachineCollider.ResolutionStrategy m_Strategy
    Field Value
    Type Description
    CinemachineCollider.ResolutionStrategy

    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(CinemachineVirtualCameraBase)

    See whether the virtual camera has been moved nby the collider

    Declaration
    public bool CameraWasDisplaced(CinemachineVirtualCameraBase vcam)
    Parameters
    Type Name Description
    CinemachineVirtualCameraBase 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
    System.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
    System.Boolean

    True if something is blocking the view

    OnDestroy()

    Cleanup

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

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

    Callcack to to 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
    System.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