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. Dismiss Notice

Resolved I have no idea how to set the X axis of the FreekLook Camera in code. Can anyone help?

Discussion in 'Cinemachine' started by KnoblePersona, Feb 11, 2021.

  1. KnoblePersona

    KnoblePersona

    Joined:
    Oct 13, 2020
    Posts:
    15
    I've been trying to get/set the x axis of the FreeLook Camera so I can set the angle of the camera to the same as a Virtual Camera when transitioning from a Virtual Camera to a FreeLook Camera. That way the camera doesn't flip back into the opposite direction if the player happened to have left it there before the transition.

    I found m_XAxsis but it just adds to the axis rather than setting it. One thing I noticed is that m_YAxis dose exactly what I was trying to do and set's the value. If I do m_YAxis = 0 in update then it locks Y to 0. However, if I do the same with m_XAxsis then nothing happens. If I do m_YAxis = 1, then the view starts to spin around. In the Axis Control in the Inspector, if I add anything to Y/Value it updates the values and axis in the scene. But If I do the same to X/Value it updates the scene, but the values stays at 0. Is this a bug? Or is it supposed to work like this?

    So my questions are:

    Is it possible to smoothly transition from a Virtual Camera to a FreeLook Camera while setting the angle to the Virtual Camera, That way it just zooms in and is ready to go?

    What's the best way to set the X axis of FreeLook?

    And is m_XAxsis and m_YAxis working as intended?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    I'm guessing that you have the FreeLook's binding mode set to Simple Follow. In that mode, X axis is always 0. If you change it to WorldSpace, it will behave more as you're expecting.

    However, I think there is a simple solution for you. Enable this in your FreeLook:

    upload_2021-2-11_8-16-20.png
     
    KnoblePersona likes this.
  3. KnoblePersona

    KnoblePersona

    Joined:
    Oct 13, 2020
    Posts:
    15
    DUDE, you're a hero! Both of these will help a ton!
     
    Gregoryl likes this.