public void updateCamera(Vector2 change)
 {
     if (m_activeCam)
     {
         m_activeCam.increasePitch(change.y);
         m_activeCam.increaseYaw(change.x);
         m_activeCam.UpdatePosition();
     }
 }
Esempio n. 2
0
    private void processInputs()
    {
        float XaxisInvert = 1.0f;
        float YaxisInvert = 1.0f;

        if (invertX)
        {
            XaxisInvert = -1.0f;
        }

        if (invertY)
        {
            YaxisInvert = -1.0f;
        }

        //Movement controls
        float verticalLeftStick = Input.GetAxis("Vertical");

        float horizontalLeftStick = Input.GetAxis("Horizontal");

        if (Mathf.Abs(verticalLeftStick) < m_moveInputThreshold)
        {
            verticalLeftStick = 0;
        }
        if (Mathf.Abs(horizontalLeftStick) < m_moveInputThreshold)
        {
            horizontalLeftStick = 0;
        }

        bool sprinting = Input.GetButton("Sprint");

        moverBehaviour.sprinting = sprinting;
        moverBehaviour.updateInput(new Vector3(verticalLeftStick, 0, horizontalLeftStick));

        float rightTrigger = Input.GetAxis("RightTrigger");
        float leftTrigger  = Input.GetAxis("LeftTrigger");

        float verticalRightStick   = Input.GetAxis("VerticalRightStick") * YaxisInvert;
        float horizontalRightStick = Input.GetAxis("HorizontalRightStick") * XaxisInvert;

        if (active)
        {
            active.increasePitch(verticalRightStick);
            active.increaseYaw(horizontalRightStick);
            active.UpdatePosition();
        }


        // ability controls

        /*
         * if (Input.GetButtonDown("Jump")) {
         *      switchCameras ();
         * targetControl.toggle();
         * }
         *
         * if (topDown) {
         *      if (Input.GetButtonDown ("Fire1")) {
         *              targetControl.activateCurrent ();
         *      }
         *      else if (Input.GetButtonUp ("Fire1")) {
         *              targetControl.disactivateCurrent ();
         *      }
         *      if (Input.GetButtonDown("Fire2")) {
         *              targetControl.toggle ();
         *      }
         * }
         */

        // hold left trigger to go top down view
        if (!topDown && leftTrigger == 1)
        {
            switchCameras();
        }
        else if (topDown && leftTrigger == 0)
        {
            switchCameras();
        }

        // press right trigger, draw
        if (rightTrigger == 1)
        {
            targetControl.toggleDraw();
            targetControl.activateCurrent();
        }
        // if detected divable object, press x to dive to it
        else if (Input.GetButtonDown("Fire3"))
        {
            if (topDown)
            {
                switchCameras();
            }
            targetControl.toggleDive();
            targetControl.activateCurrent();
        }
        // y for beacon

        /*else if (Input.GetButtonDown("Jump"))
         * {
         *
         * targetControl.toggleBeacon();
         * targetControl.activateCurrent();
         * }*/
        // otherwise, reset abilities
        else
        {
            targetControl.disactivateCurrent();
        }

        if (locator && (active == regularView || active == locator))
        {
            if (Input.GetButton("LocateOther"))
            {
                locator.gameObject.SetActive(true);
            }
            else
            {
                locator.gameObject.SetActive(false);
            }
        }

        // if holding object, press a to let go? (bcus we might want to dive under something while holding obj?)
        //if (Input.GetButtonDown("Fire1"))
        //{

        //}
    }