Search Unity

[RC3] POV cam, where is it? and how to set its axis values in script?

Discussion in 'Cinemachine' started by pleasantPretzel, Oct 7, 2017.

  1. pleasantPretzel

    pleasantPretzel

    Joined:
    Jun 12, 2013
    Posts:
    34
    I see that there isn't a POV camera to choose from in the Cinemachine menu, so I've created a standard vCam and selected POV for the Aim.

    However, now I'd like to use a custom input solution – not Unity's Input Manager – as I do for my freeLook cams. How do I access the input axis values of a vCam with a POV aim in script? I don't see access to it – maybe I'm unsure where to look or approaching this incorrectly?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You've made the POV camera the right way.
    You can access the POV public members like this:
    Code (CSharp):
    1. using Cinemahine;
    2. CinemachineVirtualCamera vcam;
    3. CinemachinePOV pov = vcam.GetCinemachineComponent<CinemachinePOV>();
    4. pov.m_HorizontalAxis.Value = bla;
    There is also pov.m_VerticalAxis. What the axis does, in its update method, is this:
    Code (CSharp):
    1. m_InputAxisValue = CinemachineCore.GetInputAxis(m_InputAxisName);
    In CinemachineCore, you'll find this:
    Code (CSharp):
    1.         /// <summary>Delegate for overriding Unity's default input system.  Returns the value
    2.         /// of the named axis.</summary>
    3.         public delegate float AxisInputDelegate(string axisName);
    4.  
    5.         /// <summary>Delegate for overriding Unity's default input system.
    6.         /// If you set this, then your delegate will be called instead of
    7.         /// System.Input.GetAxis(axisName) whenever in-game user input is needed.</summary>
    8.         public static AxisInputDelegate GetInputAxis = UnityEngine.Input.GetAxis;
    9.  
    So the default is to use Unity's input system, but you can stick your own delegate in there to drive the axis value.
     
    CFrancoChibig and a-t-hellboy like this.
  3. Dua_Loopa

    Dua_Loopa

    Joined:
    Sep 23, 2019
    Posts:
    2
    Hi, i'm faceing the same problem. I'm trying to reset/force my axis to the values you see in the screenshot.
    I'm getting errors even following your code above. maybe i'm missing something..
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    When is the vcam member set?
    Your code will fail because vcam is null.
     
    CFrancoChibig likes this.
  5. Dua_Loopa

    Dua_Loopa

    Joined:
    Sep 23, 2019
    Posts:
    2
    Fixed it. thanks