Search Unity

group composer and colliders

Discussion in 'Cinemachine' started by stuartp85, Jul 9, 2017.

  1. stuartp85

    stuartp85

    Joined:
    Jul 19, 2015
    Posts:
    1
    Hello,

    Playing around with version 2, and it seems that colliders work great, until I try using them with cameras looking at target groups. Specifically, when I have group composer selected the camera will pass through collider objects. Is this intended behaviour?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
  3. Sp4rk

    Sp4rk

    Joined:
    Sep 24, 2012
    Posts:
    19
    Hello @Gregoryl ,
    Do we have an update on this issue? I'm having the same problem (Collider doesn't work on Free Look Camera with Group Composer) and "LineOfSight" checkbox doesn't seem to exist anymore. =(
    Here it goes my screenshot of the Collider component, if it helps.
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    "Preserve Line Of Sight" is now "Avoid Obstacles". And yes, the problem is resolved.

    Be aware, however, that the occlusions are only calculated relative to the center to the target. In other words, if the target center is not occluded then the target is considered to be visible. This might not be the result you're looking for when your target is a Group.
     
  5. Sp4rk

    Sp4rk

    Joined:
    Sep 24, 2012
    Posts:
    19
    Thank you for the quick reply!
    I haven't thought of it that way, it is nice to know! But that doesn't seem to be the root of my problem...
    Here goes another screenshot with three things I think that shows it:
    1 - The Target Group Position
    2 - The FreeLook Camera Position
    3 - The actual Camera Position (passing through the wall)

    I'm loosing hair for weeks now! Do you have any idea what could be the issue?
    I'm using Unity 2018.3.13f1 and Cinemachine 2.2.7 (I tried updating to 2.2.9 but the behaviour changed drastically sending my camera to the moon, so I downgraded back).
     

    Attached Files:

    Last edited: May 23, 2019
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for trying, but it's a little hard to tell much from the still image.
    Could you export a simple project that demonstrates this, and send it to me?
     
  7. Sp4rk

    Sp4rk

    Joined:
    Sep 24, 2012
    Posts:
    19
    Sure thing! I created a little project, from scratch, and the behaviour continues...
    You can download it here:

    https://www.dropbox.com/sh/npb9g20nak0typa/AAD6NNQZXU62OHUwpG184XWia?dl=0

    Thank you for your time!
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for preparing that, it helps a lot.

    So yes, there are some modes in which the group composer and the collider don't work so well together. Specifically, if you configure the group composer to move the camera (as opposed to changing the FOV) then that movement will happen only after the collider has done its thing, effectively overriding the work of the collider.

    The workaround for this is to set the Group Composer's adjustment mode to Zoom Only (do it in all 3 rigs):

    upload_2019-5-28_11-51-19.png

    Also, I would avoid setting the FreeLook to look at and follow different things. It's too easy to get into a situation where the lookAt point and desired camera position are coincident - which is unstable. Better to set both LookAt and Follow to be the Target Group. The FreeLook will then consistently look at and orbit around the average position of the group members.

    Finally, you can simplify your code by enabling this checkbox in the vcams:

    upload_2019-5-28_11-55-55.png

    Then, the transitions will be smooth and you won't need any code in ControllableCamera.cs except targetCamera.gameObject.SetActive().
     
  9. Sp4rk

    Sp4rk

    Joined:
    Sep 24, 2012
    Posts:
    19
    Yeah!! That was it!
    There are a few other options that make the Collider don't work well, even with the mode set to Zoom Only, so it took me a while. But overall I got a pretty nice result. Awesome!

    Thank you for your time, Cinemachine is amazing and I'm eager to see what new cool stuff you guys have planned.
     
    Gregoryl likes this.
  10. giantdoor

    giantdoor

    Joined:
    Sep 11, 2018
    Posts:
    52
    Hi @Gregoryl!
    Is this still the only way to make this work, or are there any changes on this side?
    Also, does the CinemachineCollider work with the TerrainCollider? Cause I can't really tell ^^"
     
    Last edited: Jun 24, 2020
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    @giantdoor Not sure what "this" you are referring to. There are a number of new ways to set things up in Cinemachine 2.6, maybe one of them applies to your situation.
     
  12. giantdoor

    giantdoor

    Joined:
    Sep 11, 2018
    Posts:
    52
    You're right, I meant using "Zoom Only" as AdjustmentMode to make the TargetGroup/GroupComposer work with the CinemachineCollider.
    Also what about the TerrainCollider? It seems to me that it doesn't properly work with the CollideAgainst and ObstacleAvoidance turned on, as the camera can easily get stuck behind a hilly shape placed between the target and itself; it also seems that the "PreserveCameraDistance" Strategy doesn't really work with the TerrainCollider either, but maybe that's a more generic problem?
    And what about this, is there a list of new ways somewhere? Also, 2.6 is still marked as preview, is it safe for production?
    <3
     
    Last edited: Jun 24, 2020
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    If you don't want to use ZoomOnly and want to use the collider, you'd have to implement a simple version of a collider extension that only pulls the camera along its Z axis, so as to not disturb the aim, and furthermore does that after the "Aim" stage, so that it happens after the group composer. However, even if you do that, the group composer will composed based on an uncollided position, so the collider's action will disturb the composition.

    As for terrain collider, no news there sadly.

    See the 2.6 release notes for a list of new features. It's stable and safe to use in production; we are on the verge of releasing the non-preview version.
     
  14. giantdoor

    giantdoor

    Joined:
    Sep 11, 2018
    Posts:
    52
    I see, will try that then.
    No problem, what is the reason for it not working though? Is it because the TerrainCollider is a MeshCollider, but not of the Convex type? What could be a workaround? Placing invisible BoxColliders following the terrain shape, and only affecting the Camera?