Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

CinemachineCollider + CinemachineCameraOffset does not work together?

Discussion in 'Cinemachine' started by Eg1l, Mar 31, 2022.

  1. Eg1l

    Eg1l

    Joined:
    Sep 28, 2015
    Posts:
    11
    Hi. I am using CinemachineFreelook for a typical third person camera around the player character, and using the CinemachineCameraOffset as an extension so that I can get a 0.4f offset in X on the character (typical over the shoulder setup where camera is on the right side of the character). The Apply after field is set to Aim.

    However, using the CinemachineCollider extension along with this setup, it seems like the collider handling is not taking the offset into account. This causes the freelookcamera to clip into wall geometry on the right side of the character, but not on the left side of the character.

    Is there something I can do with the collider extension to make it follow offsets? Is there perhaps a way to set offset to the collider? (preferable in runtime since offset will sometimes changed based on player's state)
    The collider Strategy field is set to PullCameraForward. The rest is pretty much default setting.
     
    Last edited: Mar 31, 2022
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,267
    FreeLook isn't the best way to make a 3rd person over-the-shoulder camera, partly for reasons such as this. Instead, we recommend using the ThirdPersonFollow component, which has a well-behaved collider built-in. The paradigm to set this up is a little different, however. The camera does not directly take user input. Instead, it tracks an object that does. This tutorial might be helpful:

     
  3. Eg1l

    Eg1l

    Joined:
    Sep 28, 2015
    Posts:
    11
    Thanks. Unfortunately this setup will not work for our game. I am using freelook as you must be able to walk around while looking around similar to the Uncharted-series. An x-offset is slightly increased when camera is closer to the player in narrow spaces and indoor exploration, but offset does decrease a bit when entering combat, as this pulls out camera slightly and acts similar to the Uncharted series' camera.
    This dynamic freelook setup I got works great so far, only thing is the offset not working with collider.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,267
    You can get this behaviour with the ThirdPersonFollow setup. It's just a matter of uncoupling the rotation of the character from the camera controller object.