Search Unity

Question Freelook zoom

Discussion in 'Cinemachine' started by lucaskargreen, Sep 17, 2020.

  1. lucaskargreen

    lucaskargreen

    Joined:
    Sep 10, 2020
    Posts:
    21
    Is it possible to add zoom to a freelook camera without changing FOV?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
  3. lucaskargreen

    lucaskargreen

    Joined:
    Sep 10, 2020
    Posts:
    21
    Do you have an example of I would be able the change the orbits using a script?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    look above, I edited my previous post
     
  5. lucaskargreen

    lucaskargreen

    Joined:
    Sep 10, 2020
    Posts:
    21
    This script is using the legacy input system, do you know how I would go about changing it to the new input system as i cant just put "mouse scrollwheel" as the input axis
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Change the Awake() method to this, then it will use the attached CinemachineInputProvider's Z Axis as input.
    Code (CSharp):
    1.         void Awake()
    2.         {
    3.             freelook = GetComponentInChildren<CinemachineFreeLook>();
    4.             if (freelook != null)
    5.             {
    6.                 originalOrbits = new CinemachineFreeLook.Orbit[freelook.m_Orbits.Length];
    7.                 for (int i = 0; i < originalOrbits.Length; i++)
    8.                 {
    9.                     originalOrbits[i].m_Height = freelook.m_Orbits[i].m_Height;
    10.                     originalOrbits[i].m_Radius = freelook.m_Orbits[i].m_Radius;
    11.                 }
    12. #if UNITY_EDITOR
    13.                 SaveDuringPlay.SaveDuringPlay.OnHotSave -= RestoreOriginalOrbits;
    14.                 SaveDuringPlay.SaveDuringPlay.OnHotSave += RestoreOriginalOrbits;
    15. #endif
    16.                 var provider = freelook.GetInputAxisProvider();
    17.                 if (provider != null)
    18.                     zAxis.SetInputAxisProvider(2, provider);
    19.             }
    20.         }
     
  7. lucaskargreen

    lucaskargreen

    Joined:
    Sep 10, 2020
    Posts:
    21
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    CinemachineInputProvider is assuming that you are connecting the Z axis to a single float value input source. Either set one up in the Input system for the scroll wheel and use it, or make your own modified version of the CinemachineInputProvider script that accepts a Vector2 input source.