Search Unity

Cinemachine ClearShot Camera and Trigger collider volumes

Discussion in 'Cinemachine' started by RobO_HB, Dec 12, 2018.

  1. RobO_HB

    RobO_HB

    Joined:
    Sep 16, 2013
    Posts:
    17
    Hello,

    I've run into an issue for which I'm wondering whether there's a reasonable workaround:

    In our game, our tree trunks have regular physics colliders; however, the top part of the tree (i.e. the leaves and small branches) is made up of one or more spherical colliders marked as Triggers - physics objects don't *bounce off* the leaves or stop short, but when they enter that trigger we do various things to slow them down (and play audio, etc.).

    It seems that CinemachineCollider (used by ClearShotCamera) uses QueryTriggerInteraction.Ignore in all of the raycasts it uses to determine whether a target is obscured/occluded. Because of this, ClearShot will generally not choose cameras that are obscured by a tree trunk, but will choose a camera that is obscured by the leaves of a tree - which is not ideal.

    The only workaround I can think of is to add a duplicate set of colliders to all of the tree tops, exactly the same size as the trigger collider for the leaves, that none of our other physics layers collide with but which is not a Trigger, and then include it in the layer mask for the CinemachineCollider. However, this is a pretty big change - our environment has a huge number of trees, which means we'd probably be introducing hundreds or thousands of additional colliders into our scene, which potentially has other implications.

    Is there a way to tell a particular CinemachineCollider not to ignore trigger colliders, at least for certain layers?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    You could create your own CinemachineExtension that lowers shot quality if a raycast to target hits one of your trigger zones. Add it alongside the Collider.
     
  3. RobO_HB

    RobO_HB

    Joined:
    Sep 16, 2013
    Posts:
    17
    Hi Gregory, thanks for the suggestion, I'll give that a try.