Search Unity

Question How can I access the height and radius variables through code?

Discussion in 'Cinemachine' started by imaginereadingthis, Sep 20, 2022.

  1. imaginereadingthis

    imaginereadingthis

    Joined:
    Jul 25, 2020
    Posts:
    97
    Hello everyone,

    I have a quick question on how I can change the height and radius variables on my CinemachineFreeLook component through a script.
    upload_2022-9-19_17-41-47.png

    Does anyone know how to do this? I will need to change these values based on certain events that will affect the player's size, and I'd like to scale the camera's distance and height accordingly. I just need to know how I can change those variables for all three rigs through code instead of manually.
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    You can access it through Freelook's m_Orbit property (m_Height, m_Radius).
    Code (CSharp):
    1. var freelook = GetComponent<CinemachineFreeLook>();
    2. freelook.m_Orbits[0].m_Height = h0; // TopRig
    3. freelook.m_Orbits[1].m_Height = h1; // MiddleRig
    4. freelook.m_Orbits[2].m_Height = h2; // BottomRig
     
  3. imaginereadingthis

    imaginereadingthis

    Joined:
    Jul 25, 2020
    Posts:
    97
    thank you so much for your help!!
     
    EldarPlay01 and MikuNuonuo like this.