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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Get current orthographic size TargetGroup Camera when its not live

Discussion in 'Cinemachine' started by hosseinpanahloo, Apr 15, 2020.

  1. hosseinpanahloo

    hosseinpanahloo

    Joined:
    Jun 28, 2018
    Posts:
    11
    Hi, I'm making a strategy game. I add all the buildings to the Targetgroup camera, and the Orthographic size adjusts nicely to the main camera and I want to use this Orthographic size as the Maximum for zooming out manually.
    But the problem is when the TargetGroupVcam is not live (Another Vcam is live for zooming in and meanwhile new buildings spawn and the maximum orthographic size should change because of that). I cannot find a way to get the Orthographic size of the TargetGroupVcam.
    I tired "Vcam.m_m_Lens.OrthographicSize" but its value is not changing.
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi
    You are right, when using a target group, the vcam's orthographic size parameter does not update.
    However, the unity camera (main camera) keeps track of the change. So you could get the Orthographic size from Camera.main.
     
    Last edited: Apr 16, 2020
    Gregoryl likes this.
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,238
    A slight update to what @gaborkb said:

    Vcam.m_Lens.OrthographicSize
    will not update, and it is not supposed to. That's the initial setting of the vcam. If it has a procedural ortho size adjustment, you will find the updated ortho size in
    vcam.State.Lens.OrthographicSize
    .

    Make sure to set the vcam's Standby Update method to Always, if you want it to update when not live.

    In general, all procedurally-updated vcam properties will be found only in
    vcam.State
    , with the exception of the position/rotation (which is also pushed back to the transform, as a special-case to make things easier to follow in the scene view).
     
    Last edited: Apr 16, 2020
    Zethros likes this.
  4. hosseinpanahloo

    hosseinpanahloo

    Joined:
    Jun 28, 2018
    Posts:
    11
    Thanks guys, This is great.