// Update is called once per frame
 void Update()
 {
     if (controller.GetPressDown(triggerButton))
     {
         IPL.SetLeftTriggerInteracting(true);
     }
     if (controller.GetPressUp(triggerButton))
     {
         IPL.SetLeftTriggerInteracting(false);
     }
     if (controller.GetPressDown(gripButton))
     {
         IPL.SetLeftGripInteracting(true);
     }
     if (controller.GetPressUp(gripButton))
     {
         IPL.SetLeftGripInteracting(false);
     }
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        playerMoveX = device.GetAxis(thumbStick).x;
        playerMoveZ = device.GetAxis(thumbStick).y;
        playerMovement.transform.Translate(new Vector3(playerMoveX * moveSpeed, 0, playerMoveZ * moveSpeed));
        if (playerMoveX == 0 && playerMoveZ == 0)
        {
            rb.velocity = Vector3.zero;
        }

        if (device.GetPressDown(triggerButton))
        {
            IPL.SetLeftTriggerInteracting(true);
        }
        if (device.GetPressUp(triggerButton))
        {
            IPL.SetLeftTriggerInteracting(false);
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (controller.GetPressDown(triggerButton))
        //IPL.Set_Left_Interacting(true); IPL.Set_Player_Interacting(true);
        {
            IPL.SetLeftTriggerInteracting(true);
            if (anthology)
            {
                if (anthology.active)
                {
                    anthology.activate(true);
                }
            }
        }

        if (controller.GetPressUp(triggerButton))
        //IPL.Set_Left_Interacting(false); IPL.Set_Player_Interacting(false);
        {
            IPL.SetLeftTriggerInteracting(false);
            if (objectHovering)
            {
                objectHovering.GetComponent <Rigidbody>().isKinematic     = false;
                objectHovering.GetComponent <Rigidbody>().velocity        = controller.velocity + new Vector3(controller.velocity.x * -2, 0, controller.velocity.z * -2);
                objectHovering.GetComponent <Rigidbody>().angularVelocity = controller.angularVelocity;
            }
            if (anthology)
            {
                if (anthology.active)
                {
                    anthology.activate(true);
                }
            }
        }
        if (controller.GetPressDown(gripButton))
        //IPL.Set_Left_Interacting(true); IPL.Set_Player_Interacting(true);
        {
            IPL.SetLeftGripped(true);
            aimer.SetActive(true);
        }
        if (controller.GetPressUp(gripButton))
        //IPL.Set_Left_Interacting(false); IPL.Set_Player_Interacting(false);
        {
            aimer.SetActive(false);
            IPL.SetLeftGripped(false);
            if (IPL.leftHand.CurrentlyInteracting)
            {
                NVRInteractable test = IPL.leftHand.CurrentlyInteracting;
                StartCoroutine(delayForReactivate(test));
                test.GetComponent <NVRInteractableItem>().enabled = false;
                IPL.leftHand.EndInteraction(test);
                test.GetComponent <Rigidbody>().AddForce(raycastOrigin.transform.forward * 500);
                StartCoroutine("vibrateLeft", .1f);
                PlaySound(source, sounds[1], true);
            }
            else if (objectHovering && IPL.leftTriggerInteractive)
            {
                NVRInteractableItem test = objectHovering;
                objectHovering = null;
                test.GetComponent <Rigidbody>().isKinematic = false;
                test.GetComponent <Rigidbody>().AddForce(raycastOrigin.transform.forward * 500);
                StartCoroutine("vibrateLeft", .1f);
                PlaySound(source, sounds[1], true);
            }
        }

        if (controller.GetPressDown(aButton) || controller.GetPressDown(bButton) || controller.GetPressDown(joystickPress))
        {
            IPL.SetRightButtonInteracting(true);
            anthology.activate(true);
        }
        if (controller.GetPressUp(aButton) || controller.GetPressUp(bButton) || controller.GetPressUp(joystickPress))
        {
            IPL.SetRightButtonInteracting(false);
            anthology.activate(false);
        }


        if (!IPL.GetLeftTriggerInteracting())
        {
            hovering       = Physics.OverlapBox(raycastOrigin.transform.position + raycastOrigin.transform.forward * IPL.range, IPL.halfExtents, raycastOrigin.transform.rotation);
            objectHovering = IPL.CheckForObject(hovering, raycastOrigin.transform, false);

            //indicator.transform.position = hovering.transform.position;
            if (objectHovering)
            {
                ringDisplay.transform.position = objectHovering.transform.position;
                ringDisplay.transform.LookAt(Camera.main.transform);
            }
            playedWhoosh = false;
        }
        else
        {
            if (objectHovering) //&& !IPL.leftHand.CurrentlyInteracting)
            {
                if (!playedWhoosh)
                {
                    StartCoroutine("vibrateLeft", .1f);
                    PlaySound(source, sounds[0], true);
                    playedWhoosh = true;
                }
                objectHovering.GetComponent <Rigidbody>().isKinematic = true;
                objectHovering.transform.position = Vector3.MoveTowards(objectHovering.transform.position, raycastOrigin.transform.position, IPL.pullSpeed * Time.deltaTime);
            }
        }
        if (objectHovering && IPL.GetLeftTriggerInteracting())
        {
            pullSomething = true;
            if (objectHovering.GetComponent <PotionStack>())
            {
                pullPotion = true;
            }
            else
            {
                pullPotion = false;
            }
        }
        else
        {
            pullSomething = false;
        }
        if (objectHovering && !IPL.GetLeftTriggerInteracting())
        {
            ringDisplay.enabled = true;
        }
        else
        {
            ringDisplay.enabled = false;
        }
    }