Search Unity

Modifying First Person Controller with Potentiometer

Discussion in 'Scripting' started by danielleamya, Mar 15, 2018.

  1. danielleamya

    danielleamya

    Joined:
    Oct 12, 2015
    Posts:
    8
    Hi,

    I would like to modify the First Person Controller Script included in the Standard Asset Package to be controlled by a potentiometer instead of a computer mouse. I already have the potentiometer's rotation mapped between -90 and 90 coming into Unity via Serial Port. I believe this is the area I am looking to modify for the rotation:
    Code (CSharp):
    1.         private void RotateView()
    2.         {
    3.             m_MouseLook.LookRotation (transform, m_Camera.transform);
    4.         }
    Now I have a different script that just doesn't work quite right because it maps the Y rotation to the rotation of the potentiometer instead of making it cumulative like the one above does. If it helps, here it is:
    Code (CSharp):
    1.         rotPot_Value = arduino_obj.GetComponent<serialPort>().rotate_Value; // get values from arduino-unity script
    2.         gameObject.transform.localRotation = Quaternion.Euler(0, rotPot_Value, 0); // rotate head using this value