Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (controlActive)
        {
            dev = SteamVR_Controller.Input((int)tracked.index);
            if (dev.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                Debug.Log("Shoot");
                count++;
                if (count > fireRate)
                {
                    laser.FireVR();
                    count = 0;
                }
            }
            //if (Input.GetKeyDown("w"))
            //{
            //transform.position = new Vector3(10, 0, 10);
            //}

            //rb.AddForce(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical")));
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (vrMode)
        {
            OVRInput.Controller activeController = OVRInput.GetActiveController();

            rotationVal = OVRInput.GetLocalControllerRotation(activeController).eulerAngles;

            if (rotationVal.x > 180f)
            {
                rotationVal.x -= 360f;
            }
            if (rotationVal.y > 180f)
            {
                rotationVal.y -= 360f;
            }
            if (rotationVal.z > 180f)
            {
                rotationVal.z -= 360f;
            }
            percentageRot = rotationVal / 90f;
            //rotationVal = rot.eulerAngles;
            //transform.rotation = rot;

            if (OVRInput.Get(OVRInput.Button.Any))
            {
                Debug.Log("Shoot");
                count++;
                if (count > fireRate)
                {
                    laser.FireVR();
                    count = 0;
                }
            }
            if ((OVRInput.GetUp(OVRInput.Button.Any)))
            {
                count = fireRate;
            }
        }
        else
        {
            percentageRot = Vector3.one;
        }

        if (Mathf.Abs(rotationVal.x) > deadZone.x)
        {
            transform.Rotate(Vector3.right * Time.deltaTime * percentageRot.x * Mathf.Abs(percentageRot.x) * rotationVel.x);
            xTurn = true;
        }
        else
        {
            xTurn = false;
        }

        if (Mathf.Abs(rotationVal.z) > deadZone.z)
        {
            transform.Rotate(-Vector3.forward * Time.deltaTime * percentageRot.z * rotationVel.z);
            zTurn = true;
        }
        else
        {
            zTurn = false;
        }

        if (Mathf.Abs(rotationVal.y) > deadZone.y)
        {
            transform.Rotate(Vector3.up * Time.deltaTime * percentageRot.y * rotationVel.y);
            yTurn = true;
        }
        else
        {
            yTurn = false;
        }

        rb.velocity = transform.forward * speed;
    }