GetHairTriggerDown() 공개 메소드

public GetHairTriggerDown ( ) : bool
리턴 bool
예제 #1
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);


        // Getting the Touchpad Axis
        if (Controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(gameObject.name + Controller.GetAxis());
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            Debug.Log(gameObject.name + " Trigger Press");
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            Debug.Log(gameObject.name + " Trigger Release");
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Press");
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Release");
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (gameObject.transform.parent != null)
        {
            if (trackedObj == null)
            {
                trackedObj = gameObject.transform.parent.GetComponent <SteamVR_TrackedObject>();
                Controller = SteamVR_Controller.Input((int)trackedObj.index);
            }
            if (Controller.GetHairTriggerDown() && trackedObj != null)
            {
                if (i > 0)
                {
                    if (typefire == "Semi")
                    {
                        i--;
                        //StartCoroutine("FireSemi");
                    }
                    else if (typefire == "Auto")

                    {
                        StartCoroutine("FireAuto");
                    }
                }
                else
                {
                    magob = gameObject.transform.Find("Magazine").gameObject;
                    StartCoroutine("maglife");
                    i = mag;
                }
            }
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);

        // Getting the Touchpad Axis
        if (Controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(gameObject.name + Controller.GetAxis());
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            triggerPress = true;
//			Debug.Log(gameObject.name + " Trigger Press");
//			if (gameObject.name == "Controller (right)") {
//				InteractionManager.right_trigger_press = true;
//			} else if (gameObject.name == "Controller (left)") {
//				InteractionManager.left_trigger_press = true;
//			}
//
            //InteractionManager.ActiveHairlineTrigger(gameObject.name);

            //if we're on controller right
//			if(gameObject.name == "Controller (right)"){
//				Debug.Log ("both at the same time!!!");
//
//				//find the interaction manager and call the function we wrote
//
//				//GameObject.Find ("InteractionManager").GetComponent<Interactions> ().HandleRightTriggerPressed ();
//			}
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            triggerPress = false;
//			if (gameObject.name == "Controller (right)") {
//				InteractionManager.right_trigger_press = false;
//			} else if (gameObject.name == "Controller (left)") {
//				InteractionManager.left_trigger_press = false;
//			}
//			Debug.Log(gameObject.name + " Trigger Release");
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Press");
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Release");
        }
    }
예제 #4
0
    void ProcessController(SteamVR_Controller.Device controller, GameObject controllerGO, bool left)
    {
        if (controller == null)
        {
            //Debug.LogError("Controller not found " + left);
            return;
        }

        // 1
        if (controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(left + " " + controller.GetAxis());
        }

        // 2
        if (controller.GetHairTriggerDown())
        {
            Debug.LogError(left + " Trigger Press");
            TriggerPull(controllerGO);
        }

        // 3
        if (controller.GetHairTriggerUp())
        {
            Debug.Log(left + " Trigger Release");
        }

        // 4
        if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(left + " Grip Press");
        }

        // 5
        if (controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(left + " Grip Release");
        }

        if (controller.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
        {
            Debug.Log("STOP TOUCHING ME!");
        }

        if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            TriggerSwitch(controllerGO);
        }

        if (controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
        {
            movementScript.Respawn();
        }

        //Debug.Log("Controller " + left + " has something " + controller.index + " // " + controller.transform.pos);
    }
    // Update is called once per frame
    void Update()
    {
        // Get inputs and update mode
        if (hand.index != SteamVR_TrackedObject.EIndex.None)
        {
            SteamVR_Controller.Device controller = SteamVR_Controller.Input((int)hand.index);
            if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                Vector2 touchpad = controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad);
                float   deadzone = 0.6f;
                if (touchpad.y > deadzone)
                {
                    featuresEnabled[0] = !featuresEnabled[0];
                }
                if (touchpad.y < -deadzone)
                {
                    featuresEnabled[2] = !featuresEnabled[2];
                }
                if (touchpad.x > deadzone)
                {
                    featuresEnabled[1] = !featuresEnabled[1];
                }
                if (touchpad.x < -deadzone)
                {
                    featuresEnabled[3] = !featuresEnabled[3];
                }

                for (int i = 0; i < featuresEnabled.Length; ++i)
                {
                    if (featuresOn[i] != null)
                    {
                        featuresOn[i].SetActive(featuresEnabled[i]);
                    }
                    if (featuresOff[i] != null)
                    {
                        featuresOff[i].SetActive(!featuresEnabled[i]);
                    }
                }
            }

            if (controller.GetHairTriggerDown())
            {
                enableClouds = !enableClouds;
            }
            if (enableClouds)
            {
                RenderSettings.skybox = skyWithClouds;
            }
            else
            {
                RenderSettings.skybox = skyNoClouds;
            }
        }

        normal();
    }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);

        // Getting the Touchpad Axis
        if (Controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(gameObject.name + Controller.GetAxis());
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            GameObject go = GameObject.Find("Sphere(Clone)");

            if (go == null)
            {
                go = GameObject.Find("Cube");
            }


            //This line is the one that changes the value of photonView.isMine on the specified GameObject
            go.GetComponent <PhotonView> ().RequestOwnership();
            go.GetComponent <TransformManager> ().SetNewParent(this.transform);
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            GameObject go = GameObject.Find("Sphere(Clone)");

            if (go == null)
            {
                go = GameObject.Find("Cube");
            }

            // Make sure we have ownership before we do anything the the objects
            go.GetComponent <PhotonView> ().RequestOwnership();
            go.GetComponent <TransformManager>().DetachParent();
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Press");

            PhotonNetwork.Instantiate(spherePrefab.name, new Vector3(0, 3, 0), Quaternion.identity, 0);
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Release");
        }
    }
예제 #7
0
        private void CognitiveVR_Manager_UpdateEvent(float deltaTime)
        {
            if (GameplayReferences.HMD == null)
            {
                Core.UpdateEvent -= CognitiveVR_Manager_UpdateEvent; return;
            }
            //get left controller device
            if (leftController == null && GameplayReferences.GetControllerInfo(false, out tempInfo))
            {
                var leftObject = tempInfo.transform.GetComponent <SteamVR_TrackedObject>();
                if (leftObject != null)
                {
                    leftController = SteamVR_Controller.Input((int)leftObject.index);
                }
            }

            //get right controller device
            if (rightController == null && GameplayReferences.GetControllerInfo(true, out tempInfo))
            {
                var rightObject = tempInfo.transform.GetComponent <SteamVR_TrackedObject>();
                if (rightObject != null)
                {
                    rightController = SteamVR_Controller.Input((int)rightObject.index);
                }
            }

            if (!rightControllerTracking && rightController != null && rightController.GetHairTriggerDown())
            {
                //start coroutine if not started already
                rightControllerTracking = true;
                if (!anyControllerTracking)
                {
                    anyControllerTracking = true;
                    StartCoroutine(Tick());
                }
            }

            if (!leftControllerTracking && leftController != null && leftController.GetHairTriggerDown())
            {
                //start coroutine if not started already
                leftControllerTracking = true;
                if (!anyControllerTracking)
                {
                    anyControllerTracking = true;
                    StartCoroutine(Tick());
                }
            }

            //if both controllers are actively tracking distance, stop this callback to check for controllers that become active
            if (leftControllerTracking && rightControllerTracking)
            {
                Core.UpdateEvent -= CognitiveVR_Manager_UpdateEvent;
            }
        }
 void Update()
 {
     if (device.GetHairTriggerDown())
     {
         triggerDown = true;
     }
     if (device.GetHairTriggerUp())
     {
         triggerDown = false;
     }
 }
예제 #9
0
 void Update()
 {
     if (device.GetHairTriggerDown())
     {
         /*this.initPos = this.trackedObj.transform.position;
          * this.initTime = Time.time;
          *
          * } else if (device.GetHairTriggerUp ()) {
          * Vector3 posDiff = this.trackedObj.transform.position - this.initPos;
          * float timeDiff = Time.time - this.initTime;*/
         this.ThrowDart();
     }
 }
예제 #10
0
        //-------------------------------------------------
        // Was the standard interaction button just pressed? In VR, this is a trigger press. In 2D fallback, this is a mouse left-click.
        //-------------------------------------------------
        public bool GetStandardInteractionButtonDown()
        {
            if (noSteamVRFallbackCamera)
            {
                return(Input.GetMouseButtonDown(0));
            }
            else if (controller != null)
            {
                return(controller.GetHairTriggerDown());
            }

            return(false);
        }
예제 #11
0
    private ControllerState controllerEvents()
    {
#if SteamVR_Legacy
        if (deviceR.GetHairTriggerDown())
        {
            return(ControllerState.TRIGGER_DOWN);
        }
#elif SteamVR_2
        if (m_controllerPress.GetStateDown(trackedObjR.inputSource))
        {
            return(ControllerState.TRIGGER_DOWN);
        }
#endif
        return(ControllerState.NONE);
    }
예제 #12
0
        void ammoPouch()
        {
            //check it is the correct hand
            if (startingHandType == 0)
            {
                if (controller.GetHairTriggerDown())
                {
                    //reset ammoget
                    canGrabAmmo = false;


                    Collider[] cols = Physics.OverlapSphere(transform.position, 0.1f);

                    foreach (Collider col in cols)
                    {
                        if (col.transform.tag == "ammoPouch")
                        {
                            canGrabAmmo = true;
                        }
                    }

                    //delete array
                    cols = null;

                    if (canGrabAmmo == true)
                    {
                        var mag = (GameObject)Instantiate(
                            fullMag,
                            transform.position,
                            transform.rotation);

                        mag.transform.SetParent(transform);
                    }
                }
            }
        }
예제 #13
0
        void Update()
        {
            if (_trackedObject.index == SteamVR_TrackedObject.EIndex.None)
            {
                // No device
                // TODO: Cancel events that were in progress?
                return;
            }

            SteamVR_Controller.Device device = SteamVR_Controller.Input((int)_trackedObject.index);
            triggerPosition = device.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger).x;

            // Trigger
            bool hairTriggerBegan  = device.GetHairTriggerDown();
            bool hairTriggerActive = device.GetHairTrigger();
            bool hairTriggerEnded  = device.GetHairTriggerUp();

            if (hairTriggerBegan)
            {
                DelegateFireTriggerBegan();
            }
            if (hairTriggerActive)
            {
                DelegateFireTriggerActive();
            }
            if (hairTriggerEnded)
            {
                DelegateFireTriggerEnded();
            }

            // Grip
            bool gripBegan  = device.GetPressDown(EVRButtonId.k_EButton_Grip);
            bool gripActive = device.GetPress(EVRButtonId.k_EButton_Grip);
            bool gripEnded  = device.GetPressUp(EVRButtonId.k_EButton_Grip);

            if (gripBegan)
            {
                DelegateFireGripBegan();
            }
            if (gripActive)
            {
                DelegateFireGripActive();
            }
            if (gripEnded)
            {
                DelegateFireGripEnded();
            }
        }
예제 #14
0
            /// <summary>
            /// Get the HTC Vive controller hair trigger down state.
            /// </summary>
            /// <returns><c>true</c>, if hair trigger down was gotten, <c>false</c> otherwise.</returns>
            public bool GetHairTriggerDown()
            {
                if (VRReplay.Instance.Mode == VRReplay.ModeType.Playback)
                {
                    return(VRReplay.Instance.QueryVRInputBool(index, "HairTriggerDown", VRDeviceInputType.HairTriggerDown));
                }
                bool state = device.GetHairTriggerDown();

                if (VRReplay.Instance.Mode == VRReplay.ModeType.Record)
                {
                    if (state)
                    {
                        VRReplay.Instance.RecordVRInputBool(index, "HairTriggerDown", VRDeviceInputType.HairTriggerDown, state);
                    }
                }
                return(state);
            }
예제 #15
0
    // Update is called once per frame
    void Update()
    {
        device = SteamVR_Controller.Input((int)controller.index);
        //If finger is on touchpad
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
        {
            //Read the touchpad values
            touchpad = device.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad);


            // Handle movement via touchpad
            if (touchpad.y > 0.2f || touchpad.y < -0.2f)
            {
                // Move Forward
                player.transform.position += player.transform.forward * Time.deltaTime * (touchpad.y * speed);

                // Adjust height to terrain height at player positin
                //playerPos = player.transform.position;
                //playerPos.y = Terrain.activeTerrain.SampleHeight(player.transform.position);
                //player.transform.position = playerPos;
            }


            if (touchpad.x > 0.2f || touchpad.x < -0.2f)
            {
                // Move Forward
                player.transform.position += player.transform.right * Time.deltaTime * (touchpad.x * speed);
            }

            // handle rotation via touchpad

            /*if (touchpad.x > 0.3f || touchpad.x < -0.3f)
             * {
             *  player.transform.Rotate(0, touchpad.x * sensitivityX, 0);
             * }*/

            //Debug.Log ("Touchpad X = " + touchpad.x + " : Touchpad Y = " + touchpad.y);
        }



        if (device.GetHairTriggerDown())
        {
            player.transform.rotation = Quaternion.identity;
        }
    }
예제 #16
0
    // Update is called once per frame
    void Update()
    {
        if (rightInput.GetHairTriggerDown() || Input.GetKeyDown(KeyCode.C))
        {
            Debug.Log("Calibrating");

            //headToRootOffset = root.transform.position - (head.transform.position);// + new Vector3(0, 0, forwardDist));
            headToRootQ = Quaternion.Inverse(cam.transform.rotation) * head.transform.rotation;
            calibrated  = true;

            hmdToRControllerOffset = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.RightHand) /* - InputTracking.GetLocalPosition(VRNode.Head)*/;
            headToRHandOffset      = rightHand.transform.position - head.transform.position;

            hmdToLControllerOffset = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftHand) - UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.Head);
            headToLHandOffset      = leftHand.transform.position - head.transform.position;

            headToRHandQ = Quaternion.Inverse(UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.RightHand)) * rightHand.transform.rotation;
            headToLHandQ = Quaternion.Inverse(UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.LeftHand)) * leftHand.transform.rotation;

            Debug.Log("hmdToRControlerOffset: " + hmdToRControllerOffset);
            Debug.Log("headToRHandOffset: " + headToRHandOffset);

            //root.transform.position = InputTracking.GetLocalPosition(VRNode.Head) + headToRootOffset;

            //headSolver.enabled = true;
            //head.transform.position = InputTracking.GetLocalPosition(VRNode.Head);
        }

        if (calibrated)
        {
            head.transform.rotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.Head) * headToRootQ;
            //head.transform.position = InputTracking.GetLocalPosition(VRNode.Head) + new Vector3(0, 0, forwardDist);

            //rightHandTarget.transform.position = rightHand.transform.position;

            Vector3 controllerRightPos = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.RightHand);
            Vector3 controllerLeftPos  = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftHand);
            //Vector3 hmdPos = InputTracking.GetLocalPosition(VRNode.Head);

            rightHandTarget.transform.position = new Vector3(controllerRightPos.x * (headToRHandOffset.x / hmdToRControllerOffset.x), controllerRightPos.y, controllerRightPos.z);
            rightHand.transform.rotation       = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.RightHand) * headToRHandQ;

            leftHandTarget.transform.position = new Vector3(controllerLeftPos.x * (headToLHandOffset.x / hmdToLControllerOffset.x), controllerLeftPos.y, controllerLeftPos.z);
            leftHand.transform.rotation       = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.LeftHand) * headToLHandQ;
        }
    }
예제 #17
0
    void Update()
    {
        device = SteamVR_Controller.Input((int)trackedObject.index);

        time += Time.deltaTime;

        if (vibrate && vibrateTimer < vibrateFor)
        {
            SteamVR_Controller.Input((int)trackedObject.index).TriggerHapticPulse(1000);
            vibrateTimer += Time.deltaTime;
        }
        else
        {
            vibrate = false;
        }

        for (int i = 0; i < 3; i++)
        {
            if (time - plasmaTimes[i] > threshold)
            {
                plasmas[i].SetActive(true);
            }
        }


        if (device.GetHairTriggerDown())
        {
            if (plasmas[turn].activeSelf)
            {
                plasmas[turn].SetActive(false);
                plasmaTimes[turn] = time;
                turn = (turn + 1) % 3;
                device.TriggerHapticPulse(1000);
                GameObject ball = Instantiate(ballPrefab);
                ball.transform.position = transform.position + directionObject.forward;
                ball.GetComponent <Rigidbody>().velocity = directionObject.forward * shootPower;
                GetComponent <AudioSource>().Play();
            }
            else
            {
                vibrate      = true;
                vibrateTimer = 0;
            }
        }
    }
    // Updates the state of each controller
    void updateControllers()
    {
        for (int i = 0; i < 1; i++)
        {
            ControllerScript          script = controllerStates[i].gameObject.GetComponent <ControllerScript>();
            SteamVR_Controller.Device device = script.Controller;
            if (device == null)
            {
                continue;
            }

            Vector3 pos = controllerStates[i].gameObject.transform.position;
            int     grabbedVertIndex = controllerStates[i].grabbedVertIndex;
            bool    isGrabbing       = controllerStates[i].isGrabbing;

            // Counterintuitively.. getHairTriggerDown() only returns true on the first frame that the trigger is pulled.
            // This is good though because that's actually what we want.
            if (device.GetHairTriggerDown())
            {
                int     nearestVertIndex = nearestVertexTo(pos);
                Vector3 nearestVertPos   = transform.TransformPoint(mesh.vertices[nearestVertIndex]);
                double  dist             = (pos - nearestVertPos).magnitude;

                if (dist < minSelectionDist)
                {
                    isGrabbing       = true;
                    grabbedVertIndex = nearestVertIndex;
                }
            }

            if (device.GetHairTriggerUp())
            {
                isGrabbing = false;
            }


            controllerStates[i].isGrabbing       = isGrabbing;
            controllerStates[i].pos              = transform.InverseTransformPoint(pos);
            controllerStates[i].grabbedVertIndex = grabbedVertIndex;
            controllerStates[i].script           = script;
            controllerStates[i].device           = device;
        }
    }
예제 #19
0
    protected virtual void Update()
    {
        timeRepeat -= Time.deltaTime;
        var controllerObject = GameObject.Find("RightController");

        //HACK For trigger!!!
        bool triggerClicked = false;

        if (timeRepeat < 0)
        {
            try
            {
                trackedObject  = controllerObject.GetComponent <SteamVR_TrackedObject>();
                device         = SteamVR_Controller.Input((int)trackedObject.index);
                triggerClicked = device.GetHairTriggerDown();
                //Vector2 triggerPosition = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
                //triggerClicked = triggerPosition.x > 0.999f; // trigger treshold seems to be 0.9f
            }
            catch (NullReferenceException e) { Debug.LogWarning(e.Message); }
        }

        if (triggerClicked && triggerTime < 0)
        {
            triggerPressed();
            triggerTime    = 1f;
            triggerClicked = false;
        }

        //reset button timeout if trigger button is up
        if (SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestRight)).GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            triggerTime = -1;
        }

        if (Input.GetMouseButtonDown(0))
        {
            mousePressed();
        }

        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
        }
    }
예제 #20
0
    // Update is called once per frame
    void Update()
    {
        lineRenderer.SetPosition(0, transform.position + -transform.right * 0.02f + transform.up * 0.03f);
        lineRenderer.SetPosition(1, transform.position + -transform.right * 5 + transform.up * 0.03f);

        charge.transform.localScale = new Vector3(charge.transform.localScale.x, chargeOriginScale * m_battery, 1.0f);

        if (controller.GetHairTriggerDown() && m_battery - m_fireCost > 0)
        {
            m_battery -= m_fireCost;

            GameObject clone = (GameObject)Instantiate(bulletPrefab, transform.position + -transform.right * 0.27f + transform.up * 0.03f, transform.rotation);
            clone.transform.Rotate(new Vector3(0, 0, 1), 90);
            clone.GetComponent <Rigidbody>().AddForce(-transform.right * bulletVelocity);
        }

        if (m_battery <= m_batterySize)
        {
            m_battery += m_chargeAmount * Time.deltaTime;
        }
    }
예제 #21
0
    // Update is called once per frame
    void Update()
    {
        this.deviceL = this.leftHand.controller;
        this.deviceR = this.rightHand.controller;

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

        this.myBody.velocity = new Vector3(-h * this.moveForce, 0f, 0f);

        if (deviceL.GetPress(SteamVR_Controller.ButtonMask.Touchpad))
        {
            Vector2 touchpad = (deviceL.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0));
            print("Pressing Touchpad " + touchpad.x);
            h = touchpad.x;
            this.myBody.velocity = new Vector3(-h * this.moveForce, 0f, 0f);
        }

        if (deviceR.GetHairTriggerDown())
        {
            this.myBody.AddForce(Vector3.up * 2000f, ForceMode.Impulse);
        }
    }
예제 #22
0
        /// <summary>
        /// Get the Steam VR hair trigger down state.
        /// </summary>
        /// <returns>Trigger down state.</returns>
        public bool GetHairTriggerDown()
        {
            if (CurrentInputMode == RVInputMode.Playback)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.HasCurrentFrame() ?
                                             CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, "HairTriggerDown") : null;
                return(inputInfo == null ? false : inputInfo.HairTriggerDownState);
            }
            bool stateValue = m_DeviceImpl.GetHairTriggerDown();

            if (CurrentInputMode == RVInputMode.Record)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, "HairTriggerDown");
                if (inputInfo == null)
                {
                    inputInfo = new SteamVRInputInfo();
                }
                inputInfo.HairTriggerDownState = stateValue;
                CurrentRecording.CurrentFrame.AddInputInfo(DeviceIndex, "HairTriggerDown", inputInfo);
            }
            return(stateValue);
        }
예제 #23
0
    private void Update()
    {
        if (rightController != null)
        {
            if (rightController.GetHairTriggerDown())
            {
                rightOrbGun.Fire();
            }

            if (rightController.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                ChangeOrbType(rightOrbGun, ViveController.RIGHT, rightController.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad));
            }
        }
        else
        {
            StopCoroutine(SetupRightController());
            StartCoroutine(SetupRightController());
        }

        if (leftController != null)
        {
            if (leftController.GetHairTriggerDown())
            {
                leftOrbGun.Fire();
            }

            if (leftController.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                ChangeOrbType(leftOrbGun, ViveController.LEFT, leftController.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad));
            }
        }
        else
        {
            StopCoroutine(SetupLeftController());
            StartCoroutine(SetupLeftController());
        }
    }
예제 #24
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);

        // Getting the Touchpad Axis
        checkSwipe();
        showMode();

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            Debug.Log(gameObject.name + " Trigger Press");
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            Debug.Log(gameObject.name + " Trigger Release");
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            //Debug.Log(gameObject.name + " Grip Press");
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            //Debug.Log(gameObject.name + " Grip Release");
            GameObject lc = GameObject.Find("Controller (left)");
            GameObject rc = GameObject.Find("Controller (right)");

            lc.GetComponentInChildren <Canvas> ().enabled = !lc.GetComponentInChildren <Canvas> ().enabled;
            rc.GetComponentInChildren <Canvas> ().enabled = !rc.GetComponentInChildren <Canvas> ().enabled;
        }
        Debug.Log("SC: " + swipeCounter);
    }
예제 #25
0
    // Update is called once per frame
    void Update()
    {
        Raycasting();
        Controller = SteamVR_Controller.Input((int)trackedObj.index);


        // trigger pressed while interacting with a puzzle element. this will signify a button press (either in direction or number pad)
        if (Controller.GetHairTriggerDown() && isPointingAtPuzzle)
        {
            if (puzzleObject.GetComponentInParent <keypadButtonBehavior> ())
            {
                puzzleObject.GetComponentInParent <keypadButtonBehavior> ().hasInput = true;
            }
            else if (puzzleObject.GetComponentInParent <fixWireButtonBehavior> ())
            {
                puzzleObject.GetComponentInParent <fixWireButtonBehavior> ().hasInput = true;
            }
            else if (puzzleObject.GetComponent <TimerLockController> ())
            {
                Debug.Log("timer puzzle active");
                puzzleObject.GetComponent <TimerLockController> ().hasInput = true;
            }
        }
    }
예제 #26
0
    // Update is called once per frame
    void Update()
    {
        float    alpha    = 1f;
        Gradient gradient = new Gradient();

        gradient.SetKeys(
            new GradientColorKey[] { new GradientColorKey(Color.green, 0f), new GradientColorKey(Color.green, 1f) },
            new GradientAlphaKey[] { new GradientAlphaKey(alpha, 0f), new GradientAlphaKey(alpha, 1f) }
            );
        lr.colorGradient = gradient;

        Controller = SteamVR_Controller.Input((int)trackedObj.index);

        positions [0] = transform.position;                //new Vector3 (-2f,0.2f,0f);
        positions [1] = transform.position;                //new Vector3 (0f,0.2f,0f);
        //positions [2] = new Vector3 (2f,-2f,0f);
        lr.positionCount = positions.Length;
        lr.SetPositions(positions);

        Raycasting();

        // Getting the Touchpad Axis
        if (Controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(gameObject.name + Controller.GetAxis());

            if (transform.childCount > 2 && transform.GetChild(2).tag == "Light")
            {
                lt.intensity = Controller.GetAxis().x + 1;
            }
//			Transform go = gameObject.transform.GetChild (1);
//			go.parent = null;
//			go.transform.localScale = Vector3.one;
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            Debug.Log(gameObject.name + " Trigger Press");
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            Transform go = gameObject.transform.GetChild(2);
            go.GetComponent <PhotonView> ().RequestOwnership();
            go.GetComponent <TransformManager>().MakeVisible();
            go.GetComponent <TransformManager> ().DetachParent();
            //
            //go.parent = null;
            //go.transform.localScale = Vector3.one;
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
//			Debug.Log(gameObject.name + " Grip Press");
//			float alpha = 1f;
//			Gradient gradient = new Gradient ();
//			gradient.SetKeys (
//				new GradientColorKey[] { new GradientColorKey (Color.yellow, 0f), new GradientColorKey (Color.yellow, 1f) },
//				new GradientAlphaKey[] { new GradientAlphaKey (alpha, 0f), new GradientAlphaKey (alpha, 1f) }
//			);
//			lr.colorGradient = gradient;
//
//			//set some positions
//
//			positions [0] = transform.position;//new Vector3 (-2f,0.2f,0f);
////			var localDirection = transform.InverseTransformPoint (transform.forward);
//			//var localDirection = transform.InverseTransformDirection(transform.forward);
//			positions [1] = transform.TransformDirection(transform.forward);//hit.collider.gameObject.transform.position;//new Vector3 (0f,0.2f,0f);
//			//positions [2] = new Vector3 (2f,-2f,0f);
//			Debug.Log("fwd on yellow is: " + Vector3.forward);
//			lr.positionCount = positions.Length;
//			lr.SetPositions (positions);
//			reset = false;
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
//			Debug.Log(gameObject.name + " Grip Release");
//			reset = true;
        }
    }
예제 #27
0
        private void Update()
        {
            controllerIndex = (uint)trackedController.index;
            //Only continue if the controller index has been set to a sensible number
            //SteamVR seems to put the index to the uint max value if it can't find the controller
            if (controllerIndex >= uint.MaxValue)
            {
                return;
            }

            device = SteamVR_Controller.Input((int)controllerIndex);

            Vector2 currentTriggerAxis  = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
            Vector2 currentTouchpadAxis = device.GetAxis();

            //Trigger Pressed
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerPressed(SetButtonEvent(ref triggerPressed, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger_Press, true, currentTriggerAxis.x, ref triggerPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerReleased(SetButtonEvent(ref triggerPressed, false, 0f));
                EmitAlias(ButtonAlias.Trigger_Press, false, 0f, ref triggerPressed);
            }

            //Trigger Touched
            if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerTouchStart(SetButtonEvent(ref triggerTouched, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger_Touch, true, currentTriggerAxis.x, ref triggerTouched);
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerTouchEnd(SetButtonEvent(ref triggerTouched, false, 0f));
                EmitAlias(ButtonAlias.Trigger_Touch, false, 0f, ref triggerTouched);
            }

            //Trigger Hairline
            if (device.GetHairTriggerDown())
            {
                OnTriggerHairlineStart(SetButtonEvent(ref triggerHairlinePressed, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger_Hairline, true, currentTriggerAxis.x, ref triggerHairlinePressed);
            }
            else if (device.GetHairTriggerUp())
            {
                OnTriggerHairlineEnd(SetButtonEvent(ref triggerHairlinePressed, false, 0f));
                EmitAlias(ButtonAlias.Trigger_Hairline, false, 0f, ref triggerHairlinePressed);
            }

            //Trigger Clicked
            if (!triggerClicked && currentTriggerAxis.x == 1f)
            {
                OnTriggerClicked(SetButtonEvent(ref triggerClicked, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger_Click, true, currentTriggerAxis.x, ref triggerClicked);
            }
            else if (triggerClicked && currentTriggerAxis.x < 1f)
            {
                OnTriggerUnclicked(SetButtonEvent(ref triggerClicked, false, 0f));
                EmitAlias(ButtonAlias.Trigger_Click, false, 0f, ref triggerClicked);
            }

            //Trigger Axis
            if (Vector2ShallowEquals(triggerAxis, currentTriggerAxis))
            {
                triggerAxisChanged = false;
            }
            else
            {
                OnTriggerAxisChanged(SetButtonEvent(ref triggerAxisChanged, true, currentTriggerAxis.x));
            }

            //ApplicationMenu
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                OnApplicationMenuPressed(SetButtonEvent(ref applicationMenuPressed, true, 1f));
                EmitAlias(ButtonAlias.Application_Menu, true, 1f, ref applicationMenuPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                OnApplicationMenuReleased(SetButtonEvent(ref applicationMenuPressed, false, 0f));
                EmitAlias(ButtonAlias.Application_Menu, false, 0f, ref applicationMenuPressed);
            }

            //Grip
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
            {
                OnGripPressed(SetButtonEvent(ref gripPressed, true, 1f));
                EmitAlias(ButtonAlias.Grip, true, 1f, ref gripPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
            {
                OnGripReleased(SetButtonEvent(ref gripPressed, false, 0f));
                EmitAlias(ButtonAlias.Grip, false, 0f, ref gripPressed);
            }

            //Touchpad Pressed
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadPressed(SetButtonEvent(ref touchpadPressed, true, 1f));
                EmitAlias(ButtonAlias.Touchpad_Press, true, 1f, ref touchpadPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadReleased(SetButtonEvent(ref touchpadPressed, false, 0f));
                EmitAlias(ButtonAlias.Touchpad_Press, false, 0f, ref touchpadPressed);
            }

            //Touchpad Touched
            if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadTouchStart(SetButtonEvent(ref touchpadTouched, true, 1f));
                EmitAlias(ButtonAlias.Touchpad_Touch, true, 1f, ref touchpadTouched);
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadTouchEnd(SetButtonEvent(ref touchpadTouched, false, 0f));
                EmitAlias(ButtonAlias.Touchpad_Touch, false, 0f, ref touchpadTouched);
            }

            if (Vector2ShallowEquals(touchpadAxis, currentTouchpadAxis))
            {
                touchpadAxisChanged = false;
            }
            else
            {
                OnTouchpadAxisChanged(SetButtonEvent(ref touchpadTouched, true, 1f));
                touchpadAxisChanged = true;
            }

            // Save current touch and trigger settings to detect next change.
            touchpadAxis     = new Vector2(currentTouchpadAxis.x, currentTouchpadAxis.y);
            triggerAxis      = new Vector2(currentTriggerAxis.x, currentTriggerAxis.y);
            hairTriggerDelta = device.hairTriggerDelta;
        }
예제 #28
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (cont == null)//set controller
        {
            cont = GetComponentInParent <Hand>().controller;
        }
        else
        {
            if (speedImmune > 0)
            {
                speedImmune--;
            }
            if (punchBuffer > 0)
            {
                punchBuffer--;
            }
            if (cont.GetHairTriggerDown())
            {
                punchBuffer = punchWaiter + 1;
            }
            if (cont.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Axis0))
            {
                lFist = null;
                rFist = null;
            }


            if (lFist == null || reSync)
            {
                if (cont == SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestLeft)))
                {
                    lFist = this;
                }
                if (cont == SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestRight)))
                {
                    rFist = lFist;
                    rFist = this;
                }
            }
            if (rFist == null || reSync)
            {
                if (cont == SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestRight)))
                {
                    rFist = this;
                }
                if (cont == SteamVR_Controller.Input(SteamVR_Controller.GetDeviceIndex(SteamVR_Controller.DeviceRelation.FarthestLeft)))
                {
                    lFist = rFist;
                    lFist = this;
                }
            }
            if (rFist == this)
            {// right fist stuff
                if (speedImmune > 0)
                {
                    speedImmune--;
                }


                if (cont.GetState().rAxis0.x >= .1f || cont.GetState().rAxis0.x <= -.1f)//rotate here
                {
                    rigidScript.Rig3D.transform.Rotate(new Vector3(0, 1, 0), cont.GetState().rAxis0.x * 2f);
                }
                transform.GetChild(0).localScale = new Vector3(-50, -50, 50);//boxing glove scale
            }
            else
            {
                //setup for movement
                Vector3 ovel = rigidScript.Rig3D.velocity;
                Vector3 vel  = rigidScript.Rig3D.velocity;
                Vector2 axis = new Vector3(cont.GetState().rAxis0.x, cont.GetState().rAxis0.y);

                float y = vel.y;
                ovel.y = 0;
                vel.y  = 0;

                if (GroundScript.OnGround)
                {
                    if (axis.sqrMagnitude > .01f)
                    {
                        rigidScript.Rig3D.useGravity = false;
                        if (axis.x < 0)     //left
                        {
                            if (axis.y < 0) //backwards
                            {
                                vel += Vector3.ClampMagnitude(GroundScript.Back.normalized * Mathf.Abs(axis.y) + GroundScript.Left.normalized * Mathf.Abs(axis.x), (GroundScript.OnGround) ? Acceleration : .08f) * axis.magnitude;
                            }
                            else//forwards
                            {
                                vel += Vector3.ClampMagnitude(GroundScript.Forward.normalized * Mathf.Abs(axis.y) + GroundScript.Left.normalized * Mathf.Abs(axis.x), (GroundScript.OnGround) ? Acceleration : .08f) * axis.magnitude;
                            }
                        }
                        else//right
                        {
                            if (axis.y < 0)//backwards
                            {
                                vel += Vector3.ClampMagnitude(GroundScript.Back.normalized * Mathf.Abs(axis.y) + GroundScript.Right.normalized * Mathf.Abs(axis.x), (GroundScript.OnGround) ? Acceleration : .08f) * axis.magnitude;
                            }
                            else//forwards
                            {
                                vel += Vector3.ClampMagnitude(GroundScript.Forward.normalized * Mathf.Abs(axis.y) + GroundScript.Right.normalized * Mathf.Abs(axis.x), (GroundScript.OnGround) ? Acceleration : .08f) * axis.magnitude;
                            }
                        }
                    }
                    else
                    {
                        rigidScript.Rig3D.useGravity = true;
                    }
                }
                else
                {
                    vel += Vector3.ClampMagnitude(Head.lookDir * axis.y + Head.rightDir * axis.x, (GroundScript.OnGround) ? Acceleration : .12f) * axis.magnitude;

                    vel += Vector3.ClampMagnitude(Head.lookDir * axis.y + Head.rightDir * axis.x, (GroundScript.OnGround) ? Acceleration : .12f) * axis.magnitude;
                }
                if (vel.magnitude > MoveSpeed * axis.sqrMagnitude && ovel.magnitude > vel.magnitude)
                {
                    //this is where we move
                    vel.y = y;

                    if (GroundScript.OnGround)
                    {
                        rigidScript.Rig3D.velocity = vel * .9f;//NOW WITH 10 PERCENT TIGHTER TURNS
                    }
                }
                else if (Vector3.Dot(axis, vel) > MoveSpeed)
                {
                    //this is so we dont break velocity cap
                }
                else
                {
                    //this is also a valid move condiditon
                    vel.y = y;

                    rigidScript.Rig3D.velocity = vel;
                }
                transform.GetChild(0).localScale = new Vector3(-50, -50, -50);//fist scale
            }



            if (punchTimer > 0)//this is where we set the fists ideal location to the punch destination
            {
                idealPoint = new Vector3(0, -maxDist / 2, -.065f + maxDist / 2);
                punchTimer--;
                punchWaiter = 20;
            }
            else
            {
                if (punchWaiter > 0)//this is where we wait to punch
                {
                    punchWaiter--;
                    if (transform.localPosition == idealPoint && punchWaiter < 19)
                    {
                        punchWaiter = 0;
                    }
                }
                else if (punchBuffer > 0)//this is where we punch
                {
                    canLaunch  = true;
                    punchTimer = 20;
                    if (whoosh != null)
                    {
                        whoosh.pitch = Random.Range(0.8f, 1.2f); // randomizes pitch
                        whoosh.Play();                           // plays whoosh sound when punch
                    }
                }
                idealPoint = new Vector3(0, 0, -.065f);
            }



            transform.localPosition = transform.localPosition + Vector3.ClampMagnitude(idealPoint - transform.localPosition, maxSpeed);

            if (cont.GetPress(Valve.VR.EVRButtonId.k_EButton_Grip) && Physics.Raycast(transform.position - (transform.forward - transform.up).normalized * .1f, transform.forward - transform.up, maxDist))
            {
                for (int i = 0; i < transform.childCount; i++)
                {
                    if (transform.GetChild(i).CompareTag("Projection"))
                    {
                        transform.GetChild(i).gameObject.SetActive(true);
                    }
                }
            }
            else
            {
                for (int i = 0; i < transform.childCount; i++)
                {
                    if (transform.GetChild(i).CompareTag("Projection"))
                    {
                        transform.GetChild(i).gameObject.SetActive(false);
                    }
                }
            }
            if (cont.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis1).x > .01 && Physics.Raycast(transform.position - (transform.forward - transform.up).normalized * .1f, transform.forward - transform.up, out info, .4f))
            {
                if (info.transform.tag == "playButton")
                {
                    Scene currentScene = SceneManager.GetActiveScene();
                    SceneManager.LoadScene((currentScene.buildIndex + 1) % SceneManager.sceneCountInBuildSettings);
                }
                if (info.transform.tag == "Enemy")
                {
                    Destroy(info.transform.gameObject);
                }
                if (info.transform.tag == "Missile")
                {
                    Destroy(info.transform.gameObject);
                }
                if (info.transform.tag != "Boost" && info.transform.tag != "enemy" && info.transform.name != "Player" && canLaunch)
                {
                    canLaunch = false;
                    cont.TriggerHapticPulse(3000, Valve.VR.EVRButtonId.k_EButton_Axis4);
                    Vector3 vel = rigidScript.Rig3D.velocity;
                    vel.y = 0;
                    if ((vel + ((transform.forward - transform.up).normalized * -.3f / Time.deltaTime * .55f)).magnitude < vel.magnitude)
                    {
                        vel += ((transform.forward - transform.up).normalized * -.3f / Time.deltaTime * .55f) * 2;
                    }
                    else
                    {
                        vel += ((transform.forward - transform.up).normalized * -.3f / Time.deltaTime * .55f);
                    }

                    punchTimer = 0;
                    rigidScript.Rig3D.velocity = vel;
                    if (info.collider.gameObject.tag == "Pillar")
                    {
                        rigidScript.Rig3D.AddForce(((transform.forward - transform.up).normalized * -.3f / Time.deltaTime * 800f * 2));
                    }

                    if (punch != null)
                    {
                        punch.pitch = Random.Range(0.8f, 1.2f);
                        punch.Play();
                    }
                }
            }
        }
        if (speedImmune > 0)
        {
            rigidScript.Rig3D.velocity = Vector3.ClampMagnitude(rigidScript.Rig3D.velocity, 25 * speedImmune * speedImmune);
        }
        else
        {
            rigidScript.Rig3D.velocity = Vector3.ClampMagnitude(rigidScript.Rig3D.velocity, 25);
        }

        prevLocalPos = transform.localPosition;
        prevpos      = transform.position;

        ////////////Wind Sounds///////////
        if (wind != null)
        {
            if (GroundScript.OnGround)
            {
                wind.volume -= 0.5f * Time.deltaTime; // fade out
            }

            else if (rigidScript.Rig3D.velocity.magnitude != 0)
            {
                wind.volume = (rigidScript.Rig3D.velocity.magnitude / 25); // wind volume depends on velocity
            }


            else
            {
                wind.volume -= 0.2f * Time.deltaTime; // fade out
            }
        }
        /////////Footstep Sounds/////////
        if (foot1 != null)
        {
            int num = Random.Range(1, 3);
            if (GroundScript.OnGround && rigidScript.Rig3D.velocity.magnitude > 1.0f && rigidScript.Rig3D.velocity.magnitude < 5.0f && timeForSteps > 50.0f) // walking speed
            {
                foot1.pitch = Random.Range(0.8f, 1.2f);
                foot1.Play();
                timeForSteps = 0;
            }

            else if (GroundScript.OnGround && rigidScript.Rig3D.velocity.magnitude >= 5.0f && timeForSteps > 25.0f) // running speed
            {
                foot1.pitch = Random.Range(0.8f, 1.2f);
                foot1.Play();
                timeForSteps = 0;
            }
            timeForSteps++;
        }
        //////////Landing Sound///////////
        if (wind != null)
        {
            if (GroundScript.OnGround == false)
            {
                wasInAir = true;
            }

            if (GroundScript.OnGround == true && wasInAir == true)
            {
                landing.Play();
                wasInAir = false;
            }
        }
    }
예제 #29
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);


//		Controller.TriggerHapticPulse (700);
//		if(Controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)){
//
//			Debug.Log("Yeah boiiiiiiii");
//		}

        // Getting the Touchpad Axis
        if (gameObject.name == "Controller (left)")
        {
            checkSwipe();
            showMode();
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            Debug.Log(gameObject.name + " Trigger Press");
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            Debug.Log(gameObject.name + " Trigger Release");
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            //Debug.Log(gameObject.name + " Grip Press");
            //anim.StopPlayback();
            //anim.enabled = false;
            //anim.isActiveAndEnabled = false;
            //anim.
            //anim.stop
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            //Debug.Log(gameObject.name + " Grip Release");


            lc.GetComponentInChildren <Canvas> ().enabled = !lc.GetComponentInChildren <Canvas> ().enabled;
            rc.GetComponentInChildren <Canvas> ().enabled = !rc.GetComponentInChildren <Canvas> ().enabled;

            displayMenus = lc.GetComponentInChildren <Canvas> ().enabled;

            if (!displayMenus)
            {
                swipeCountPrev = swipeCounter;
                swipeCounter   = 100;
            }
            else
            {
                swipeCounter = swipeCountPrev;
            }

            manager.GetComponent <prefabDisplay>().showPrefabs = displayMenus;
        }
        //Debug.Log ("SC: " + swipeCounter);
    }
예제 #30
0
        //EMPTY
        #region PUBLIC_METHODS
        #endregion PUBLIC_METHODS


        #region PRIVATE_METHODS
        /// <summary>
        /// Handle the Left Controller input and put them in the Events
        /// </summary>
        public void CheckControllerInput(VRInputsEvents clickEvents, VRInputsEvents touchEvents, VRInputsBoolean clickBools, VRInputsBoolean touchBools, SteamVR_Controller.Device controller, Vector2Variable thumbOrientation)
        {
            BoolVariable tempClick;
            BoolVariable tempTouch;

            #region TRIGGER
            tempClick = clickBools.Get("TriggerIsDown");
            tempTouch = touchBools.Get("TriggerIsTouching");

            // Check Click Events
            if (!tempClick.Value && controller.GetHairTriggerDown())
            {
                tempClick.SetValue(true);
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("TriggerDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetHairTriggerUp())
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("TriggerUp");
                _tempEvent.Raise();
            }
            // Check Touch Events if user is not clicking
            else if (!tempClick.Value && !tempTouch.Value && controller.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                tempTouch.SetValue(true);
                _tempEvent = (GameEvent)touchEvents.Get("TriggerStartTouching");
                _tempEvent.Raise();
            }
            else if (tempTouch.Value && controller.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)touchEvents.Get("TriggerStopTouching");
                _tempEvent.Raise();
            }
            #endregion TRIGGER

            #region TOUCHPAD
            thumbOrientation.SetValue(controller.GetAxis());

            tempClick = clickBools.Get("ThumbIsDown");
            tempTouch = touchBools.Get("ThumbIsTouching");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempClick.SetValue(true);
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("ThumbDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("ThumbUp");
                _tempEvent.Raise();
            }
            // Check Touch Events if user is not clicking
            else if (!tempClick.Value && !tempTouch.Value && controller.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempTouch.SetValue(true);
                _tempEvent = (GameEvent)touchEvents.Get("ThumbStartTouching");
                _tempEvent.Raise();
            }
            else if (tempTouch.Value && controller.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)touchEvents.Get("ThumbStopTouching");
                _tempEvent.Raise();
            }
            #endregion TOUCHPAD

            #region GRIP
            tempClick = clickBools.Get("GripIsDown");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
            {
                tempClick.SetValue(true);
                _tempEvent = (GameEvent)clickEvents.Get("GripDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("GripUp");
                _tempEvent.Raise();
            }
            #endregion GRIP

            #region MENU
            tempClick = clickBools.Get("MenuIsDown");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                tempClick.SetValue(true);
                _tempEvent = (GameEvent)clickEvents.Get("MenuDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("MenuUp");
                _tempEvent.Raise();
            }
            #endregion MENU
        }