Search Unity

Resolved Cinemachine Confiner does not prevent orthographic size changes

Discussion in 'Cinemachine' started by Goty-Metal, Apr 13, 2021.

  1. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Hi there! so i'm experiencing this issue, even if the camera is confined you can use a script to zoom in/out (increasing or decreasing the orthographic size of the lens) OUT of the confiner.

    Is there any way to prevent this? maybe checking of the new orthographic size exceeds the confiner? thanks!
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi
    The new CinemachineConfiner2D extension will respect orthographic size changes. Use that instead of CinemachineConfiner with 2D mode.
     
    Goty-Metal likes this.
  3. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Hey! thanks for the fast reply, unfortunately i can't find the "CinemachineConfiner2D" extension, i'm using 2.6.4

    upload_2021-4-13_17-22-4.png

    upload_2021-4-13_17-23-2.png
     
  4. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Finally, the package manager didn't show the correct latest version, i've updated to 2.7.3, sadly it still doesn't confine the camera if i change the orthographic size as it supposed to do...
     
  5. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Could you send some images of what's happening and what you'd like to happen?
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The CinemachineConfiner2D confines the camera's position, not the ortho size. Ortho size is an input to the confiner. Clamping the ortho size itself is something that you will have to implement on your own.
     
    javernaut and Goty-Metal like this.
  7. Goty-Metal

    Goty-Metal

    Joined:
    Apr 4, 2020
    Posts:
    168
    Thanks, i changed to CinemachineConfiner2D because was supposed to confine orthosize changes but it doesn't, so don't worry i'll hnadly it by myself, thanks!
     
  8. KevinLovesUnity

    KevinLovesUnity

    Joined:
    Aug 26, 2023
    Posts:
    1
    I am trying to do something similar with zoom in/out by adjusting the orthographic size. Could you explain how to clamp the orthographic size if the new one extends past the confiner?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    That's difficult to do in a general way. What does "extends past the confiner" mean in the case of a complex polygon as a confining shape? Maybe one good approach is to markup your game areas with maximum ortho size values in each of the areas, and have a script that clamps it according to those values.