GetTouch() public méthode

public GetTouch ( EVRButtonId buttonId ) : bool
buttonId EVRButtonId
Résultat bool
    void FixedUpdate()
    {
        device = SteamVR_Controller.Input ((int)trackedObj.index);

        if (device.GetTouch (SteamVR_Controller.ButtonMask.Trigger)) {
            Debug.Log ("You are holding 'touch' on the trigger");
        }
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated TouchDown on the trigger");
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated TouchUp on the trigger");
        }

        if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding 'press' on the trigger");
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated PressDown on the trigger");
        }
        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            Debug.Log("You activated PressUp on the touchpad");
            sphere.transform.position = Vector3.zero;
            sphere.GetComponent<Rigidbody>().velocity = Vector3.zero;
            sphere.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
        }
    }
    // Update is called once per frame
    void Update()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);
        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            touchLast = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
        }
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
        {
            touchCurrent = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad).x;
            distance     = touchCurrent - touchLast;
            touchLast    = touchCurrent;
            swipeSum    += distance;

            if (!hasSwipedRight)
            {
                if (swipeSum > 0.5f)
                {
                    swipeSum = 0;
                    SwipeRight();
                    hasSwipedRight = true;
                    hasSwipedLeft  = false;
                }
            }

            if (!hasSwipedLeft)
            {
                if (swipeSum < -0.5f)
                {
                    swipeSum = 0;
                    SwipeLeft();
                    hasSwipedLeft  = true;
                    hasSwipedRight = false;
                }
            }
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            swipeSum       = 0;
            touchCurrent   = 0;
            touchLast      = 0;
            hasSwipedLeft  = false;
            hasSwipedRight = false;
        }
        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            //Spawn object currently selected by menu
            SpawnObject();
        }
    }
Exemple #3
0
 void fixedUpdate()
 {
     device = SteamVR_Controller.Input((int)trackedObj.index);
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
     }
     //Activated PressUp on the TouchPad
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
     {
         sphere.transform.position = Vector3.zero;
         sphere.GetComponent <Rigidbody>().velocity        = Vector3.zero;
         sphere.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
     }
 }
Exemple #4
0
 void FixedUpdate()
 {
     device = SteamVR_Controller.Input((int)trackedObj.index);
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have collided with while holding down Touch");
         //ShipMovement.movementSpeed += .01f;
     }
     else
     {
         Debug.Log("You have collided with while holding down Touch");
         //ShipMovement.movementSpeed -= .01f;
     }
 }
Exemple #5
0
 protected override void InputSystemUpdateRightHandler(WandRight group)
 {
     base.InputSystemUpdateRightHandler(group);
     if (rightController.GetTouch(touchPad))
     {
         var moveEvent = new PlayerMoveEvent();
         moveEvent.movement = rightController.GetAxis(touchPad) * Time.deltaTime;
         Publish(moveEvent);
     }
     if (rightController.GetPressDown(touchPad))
     {
         Publish(new JumpEvent());
     }
 }
    void OnTriggerStay(Collider col)
    {
        if (device == null)
        {
            return;
        }

        // Grab a single object
        if (device.GetTouch(triggerButton) && (col.attachedRigidbody != null) &&
            (grabbedObject == null))
        {
            if (!col.attachedRigidbody.isKinematic)
            {
                grabbedObject = col.gameObject;
                Debug.Log("grabbedObject: " + grabbedObject.name);

                col.attachedRigidbody.isKinematic = true;
                grabbedObject.transform.SetParent(gameObject.transform);

                TriggerAudio grabbedTriggerScript = grabbedObject.GetComponent <TriggerAudio> ();
                if (grabbedTriggerScript != null)
                {
                    grabbedTriggerScript.MakeContact();
                }
            }
            else if (col.gameObject.name.Contains("door") || col.gameObject.name.Contains("lamp_head"))
            {
                grabbedObject = col.gameObject;
                Debug.Log("grabbedObject: " + grabbedObject.name);

                DoorBehavior doorScript = grabbedObject.GetComponent <DoorBehavior>();
                doorScript.GrabDoor(gameObject);
            }
        }
//		// Release/toss an object
//		if ((col.gameObject == grabbedObject) && device.GetTouchUp (triggerButton)) {
//
//			if (grabbedObject.name.Contains ("door")) {
//				DoorBehavior doorScript = grabbedObject.GetComponent<DoorBehavior>();
//				doorScript.ReleaseDoor ();
//				grabbedObject = null;
//			} else {
//				grabbedObject.transform.SetParent (null);
//				col.attachedRigidbody.isKinematic = false;
//				tossObject (col.attachedRigidbody);
//				grabbedObject = null;
//			}
//		}
    }
Exemple #7
0
    // Update is called once per frame
    void Update()
    {
                #if UNITY_STANDALONE_WIN
        SteamVR_Controller.Device device = SteamVR_Controller.Input((int)controller.index);

        if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
        {
            cursorsize = (device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0) [0] + 1) * 0.1f;



            cursor.transform.localScale = new Vector3(cursorsize, cursorsize, cursorsize);
        }
                #endif
    }
 void onTriggerStay(Collider col)
 {
     if ((fixedJoint == null) && (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)))
     {
         fixedJoint = col.gameObject.AddComponent <FixedJoint>();
         fixedJoint.connectedBody = rigidBodyAttachPoint;
     }
     else if ((fixedJoint != null) && (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger)))
     {
         GameObject go        = fixedJoint.gameObject;
         Rigidbody  rigidBody = go.GetComponent <Rigidbody>();
         Object.Destroy(fixedJoint);
         fixedJoint = null;
     }
 }
Exemple #9
0
        protected override void CheckForButtonInput(KeyValuePair <ButtonGesture, Action> binding)
        {
            SteamVR_Controller.Device device = SteamVR_Controller.Input(m_controllerNumber);
            switch (binding.Key.ButtonAction)
            {
            case ButtonAction.OnPressDown:
                if (device.GetPressDown(m_buttonBindings[binding.Key]))
                {
                    binding.Value();
                }
                break;

            case ButtonAction.OnPress:
                if (device.GetPress(m_buttonBindings[binding.Key]))
                {
                    binding.Value();
                }
                break;

            case ButtonAction.OnPressUp:
                if (device.GetPressUp(m_buttonBindings[binding.Key]))
                {
                    binding.Value();
                }
                break;

            case ButtonAction.OnTouchDown:
                if (device.GetTouchDown(m_buttonBindings[binding.Key]))
                {
                    binding.Value();
                }
                break;

            case ButtonAction.OnTouch:
                if (device.GetTouch(m_buttonBindings[binding.Key]))
                {
                    binding.Value();
                }
                break;

            case ButtonAction.OnTouchUp:
                if (device.GetTouchUp(m_buttonBindings[binding.Key]))
                {
                    binding.Value();
                }
                break;
            }
        }
        protected virtual void SwitchButtonAction(KeyValuePair <ButtonGesture, ulong> binding)
        {
            SteamVR_Controller.Device device = SteamVR_Controller.Input(m_controllerNumber);
            switch (binding.Key.ButtonAction)
            {
            case ButtonAction.OnPressDown:
                if (device.GetPressDown(binding.Value))
                {
                    m_buttonEvents[binding.Key]();
                }
                break;

            case ButtonAction.OnPress:
                if (device.GetPress(binding.Value))
                {
                    m_buttonEvents[binding.Key]();
                }
                break;

            case ButtonAction.OnPressUp:
                if (device.GetPressUp(binding.Value))
                {
                    m_buttonEvents[binding.Key]();
                }
                break;

            case ButtonAction.OnTouchDown:
                if (device.GetTouchDown(binding.Value))
                {
                    m_buttonEvents[binding.Key]();
                }
                break;

            case ButtonAction.OnTouch:
                if (device.GetTouch(binding.Value))
                {
                    m_buttonEvents[binding.Key]();
                }
                break;

            case ButtonAction.OnTouchUp:
                if (device.GetTouchUp(binding.Value))
                {
                    m_buttonEvents[binding.Key]();
                }
                break;
            }
        }
Exemple #11
0
    //Either navigation or menu activation
    private void handleTouchpads()
    {
        if (device.GetTouch(TOUCHPAD))
        {
            if (isNavigationController)
            {
                if (enableMovement)
                {
                    movement.enablePointer(true);
                    movement.aimFrom(viveController.transform);
                }
            }
            else
            {
                menu.enable();
            }
        }

        if (device.GetPressDown(TOUCHPAD))
        {
            if (isNavigationController)
            {
                if (enableMovement)
                {
                    movement.moveToPointer();
                }
            }
            else
            {
                this.onMenuPress();
            }
        }

        if (device.GetTouchUp(TOUCHPAD))
        {
            if (isNavigationController)
            {
                if (enableMovement)
                {
                    movement.enablePointer(false);
                }
            }
            else
            {
                menu.disable();
            }
        }
    }
Exemple #12
0
 //called for every frame
 void FixedUpdate()
 {
     device = SteamVR_Controller.Input((int)trackedObj.index);
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         //Debug.Log("holding down touch trigger");
     }
     if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
     {
         //Debug.Log("activated touch down");
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         //Debug.Log("activated touch up");
     }
 }
Exemple #13
0
 void OnTriggerStay(Collider col)
 {
     Debug.Log("You have collided with " + col.name + " and activated OnTriggerStay");
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have collided with " + col.name + " while holding down touch.");
         col.attachedRigidbody.isKinematic = true;                      //makes it so the sphere is not being affected by the physics system
         col.gameObject.transform.SetParent(this.gameObject.transform); // attaches the sphere to the controller
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have released touch while colliding with " + col.name);
         col.attachedRigidbody.isKinematic = false;
         col.gameObject.transform.SetParent(null);              // removes the controller as parent
     }
 }
Exemple #14
0
 // Update is called once per frame
 void Update()
 {
     if ((device.GetTouch(SteamVR_Controller.ButtonMask.Trigger)) && (grabbedGameObject = checkSphereAroundHand(transform.position, maxDistanceToGrab)) != null && isGrabbing == false)
     {
         //grab
         //do something to grabbedGameObject
         isGrabbing = true;
         startGrabbing(grabbedGameObject);
     }
     else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger) && grabbedGameObject != null && isGrabbing)
     {
         //drop or throw
         isGrabbing = false;
         dropOrThrow(grabbedGameObject);
     }
 }
Exemple #15
0
 void OnTriggerStay(Collider col)
 {
     Debug.Log("You have collided with " + col.name + " and activated OnTriggerStay");
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger) && col.tag == "Chest")
     {
         Debug.Log("You have collided with " + col.name + " while holding down Touch");
         col.attachedRigidbody.isKinematic = true;
         col.gameObject.transform.SetParent(gameObject.transform);
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger) && col.tag == "Chest")
     {
         Debug.Log("You have collided with " + col.name + " while holding down Touch");
         col.gameObject.transform.SetParent(null);
         col.attachedRigidbody.isKinematic = false;
     }
 }
Exemple #16
0
    void ControlScoreBoard()
    {
        if (!isJointed && device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            isJointed = true;
            fixedJoint.connectedBody = hitInfo.rigidbody;
            device.TriggerHapticPulse(2500);
        }
        else if (isJointed)
        {
            lineRenderer.material.color = jointedColor;
            reticle.GetComponentInChildren<Image>().color = jointedColor;
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                isJointed = false;
                fixedJoint.connectedBody = null;
                device.TriggerHapticPulse(2500);
            }
            else if (device.GetPress(SteamVR_Controller.ButtonMask.Touchpad))  //ScoreBoardの遠近
            {
                fixedJoint.connectedBody = null;
                var diffVector = hitInfo.point - hitInfo.transform.position;
                hitInfo.transform.position = transform.position - diffVector + transform.forward * Mathf.Clamp(hitInfo.distance + device.GetAxis().y * 0.05f, 0.5f, lineLength * 0.8f);

                hitInfo.transform.localScale = originalScaleScore * hitInfo.distance * 0.6f;
                fixedJoint.connectedBody = hitInfo.rigidbody;
            }
            else if (device.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))  //ScoreBoardの回転
            {
                if(prevAxis_x != 0)
                {
                    fixedJoint.connectedBody = null;
                    hitInfo.transform.rotation = hitInfo.transform.rotation * Quaternion.AngleAxis((device.GetAxis().x - prevAxis_x) * 20f, Vector3.up);
                    if (Vector3.Angle(-transform.forward, hitInfo.normal) < 50)
                        prevRotation = hitInfo.transform.rotation;
                    else if(Vector3.Angle(-transform.forward, hitInfo.normal) > 65) //回転制限
                        hitInfo.transform.rotation = prevRotation;
                    fixedJoint.connectedBody = hitInfo.rigidbody;
                }
                prevAxis_x = device.GetAxis().x;
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                prevAxis_x = 0f;
            }
        }
    }
Exemple #17
0
 void OnTriggerStay(Collider col)
 {
     Debug.Log("You have collided with " + col.name + " and Activated onTriggerStay");
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have collided with " + col.name + " while on touch");
         col.attachedRigidbody.isKinematic = true;
         col.gameObject.transform.SetParent(gameObject.transform);
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You are Activated touchup the Trigger " + col.name + " while on touch");
         col.gameObject.transform.SetParent(null);
         col.attachedRigidbody.isKinematic = false;
         tossObject(col.attachedRigidbody);
     }
 }
Exemple #18
0
 void OnTriggerStay(Collider col)
 {
     Debug.Log("You have collided with " + col.name + " and activated OnTriggerStay");
     if (fixedJoint == null && device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         fixedJoint = col.gameObject.AddComponent <FixedJoint> ();
         fixedJoint.connectedBody = rigidBodyAttachPoint;
     }
     else if (fixedJoint != null && device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         GameObject go = fixedJoint.gameObject;             //this should be the sphere
         Rigidbody  rb = go.GetComponent <Rigidbody>();     //collided object
         Object.Destroy(fixedJoint);
         fixedJoint = null;
         tossObject(rb);
     }
 }
    // 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;
        }
    }
Exemple #20
0
    // Update is called once per frame
    void Update()
    {
        foreach (Hand hand in player.hands)
        {
            SteamVR_Controller.Device controller = hand.controller;

            if (controller != null)
            {
                if (controller.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
                {
                    Vector2 axis0 = controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);

                    player.gameObject.transform.position += (hand.transform.right * axis0.x + hand.transform.forward * axis0.y) * flySpeed * Time.deltaTime;
                }
            }
        }
    }
    void OnTriggerStay(Collider col)
    {
        //print("Collided with " + col.name);

        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            col.attachedRigidbody.isKinematic = true;
            col.gameObject.transform.SetParent(gameObject.transform);
        }

        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            col.gameObject.transform.SetParent(null);
            col.attachedRigidbody.isKinematic = false;
            TossObject(col.attachedRigidbody);
        }
    }
Exemple #22
0
 void OnTriggerStay(Collider col)
 {
     Debug.Log("You have collided with" + col.name + " and activated onTriggerStay");
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have collided with" + col.name + "While holding down touch");
         col.attachedRigidbody.isKinematic = true;
         col.gameObject.transform.SetParent(this.gameObject.transform);
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
     {
         Debug.Log("You have released Touch while colliding with" + col.name);
         col.gameObject.transform.SetParent(null);
         col.attachedRigidbody.isKinematic = false;
         tossObject(col.attachedRigidbody);
     }
 }
Exemple #23
0
    void FixedUpdate()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);

        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding 'Touch' on the Trigger");
        }

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated TouchDown on the Trigger");
        }

        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated TouchUp on the Trigger");
        }

        if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding 'Press' on the Trigger");
        }

        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated PressDown on the Trigger");
        }

        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated PressUp on the Trigger");
        }

        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            Debug.Log("You activated PressUp on the Touchpad");
            main.l_go_PlayerUnits.Add(GameObject.Instantiate(prefabSphere).GetComponent <PickUpableObject>());
            main.l_go_PlayerUnits[main.l_go_PlayerUnits.Count - 1].main = main;

            //sphere.transform.position = Vector3.zero;
            //sphere.GetComponent<Rigidbody>().velocity = Vector3.zero;
            //sphere.GetComponent<Rigidbody>().angularVelocity = Vector3.zero;
        }
    }
Exemple #24
0
    private void OnTriggerStay(Collider col) //col is collider the the contorler has collided with
    {
        Debug.Log("You have collided with " + col.name + "and activated OnTriggerStay");
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You have collided with " + col.name + "while holding down Touch");
            col.attachedRigidbody.isKinematic = true; //so physics doesn't affect it while holding it
            col.gameObject.transform.SetParent(this.gameObject.transform);
        }
        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You have released Touch while colliding with" + col.name);
            col.gameObject.transform.SetParent(null);
            col.attachedRigidbody.isKinematic = false;

            tossObject(col.attachedRigidbody);
        }
    }
Exemple #25
0
 void OnTriggerStay(Collider other)
 {
     if (other.tag == "key")
     {
         if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
         {
             Debug.Log("Object grabbed");
             other.attachedRigidbody.isKinematic = true;
             other.gameObject.transform.SetParent(gameObject.transform);
         }
         if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
         {
             Debug.Log("Object dropped");
             other.attachedRigidbody.isKinematic = false;
             other.gameObject.transform.SetParent(null);
         }
     }
 }
Exemple #26
0
    void OnTriggerStay(Collider col)
    {
        Debug.Log("You collided with " + col.name + " and activated OnTriggerStay.");

        if (dev.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You have collided with " + col.name + " while holding down Touch");

            col.gameObject.transform.SetParent(gameObject.transform); // refers to the controllers
        }

        if (dev.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You have collided with " + col.name + " while holding down Touch");

            col.gameObject.transform.SetParent(null); // refers to the controllers
        }
    }
Exemple #27
0
    // Update is called once per frame
    void fixedUpdate()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);
        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding 'Touch' on the Trigger.");
        }

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated TouchDown on the Trigger.");
        }

        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated TouchUp on the Trigger.");
        }
    }
Exemple #28
0
 // Update is called once per frame
 void Update()
 {
     SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);
     if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
     {
         GameObject line = new GameObject();
         currLine = line.AddComponent <LineRenderer> ();
         currLine.SetWidth(0.1f, 0.1f);
         numClicks = 0;
     }
     else if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
     {
         currLine.SetVertexCount(numClicks + 1);
         Vector3 pos = trackedObj.transform.position;
         currLine.SetPosition(numClicks, pos);
         numClicks++;
     }
 }
Exemple #29
0
 protected override void InputSystemUpdateLeftHandler(WandLeft group)
 {
     base.InputSystemUpdateLeftHandler(group);
     if (leftController.GetTouch(touchPad))
     {
         var moveEvent = new RigMoveEvent();
         moveEvent.movement = leftController.GetAxis(touchPad) * Time.deltaTime;
         Publish(moveEvent);
     }
     if (leftController.GetPressDown(menuButton))
     {
         Publish(new MenuEvent());
     }
     if (!leftController.GetPress(triggerButton) && grabbedGameObject != null)
     {
         grabbedGameObject.transform.SetParent(null);
     }
 }
    void FixedUpdate()
    {
        device = SteamVR_Controller.Input((int)trackedObj.index);

        if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding 'Touch' on the trigger");
        }

        if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated 'TouchDown' on the trigger");
        }

        if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated 'TouchUp' on the trigger");
        }

        if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You are holding 'Press' on the trigger");
        }

        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated 'PressDown' on the trigger");
        }

        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            Debug.Log("You activated 'PressUp' on the trigger");
        }

        if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            Debug.Log("You activated 'PressUp' on the TouchPad");

            sphere.transform.position = Vector3.zero;
            var sphereRigidBody = sphere.GetComponent <Rigidbody>();
            sphereRigidBody.velocity        = Vector3.zero;
            sphereRigidBody.angularVelocity = Vector3.zero;
        }
    }
 void OnTriggerStay(Collider col)
 {
     if (device.GetTouch(SteamVR_Controller.ButtonMask.Grip) && col.gameObject.tag == "Keyboard")
     {
         foreach (Rigidbody rb in keyRigidbodies)
         {
             rb.isKinematic = true;
         }
         col.transform.SetParent(this.gameObject.transform);
     }
     if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Grip) && col.gameObject.tag == "Keyboard")
     {
         foreach (Rigidbody rb in keyRigidbodies)
         {
             rb.isKinematic = false;
         }
         col.transform.SetParent(null);
     }
 }
Exemple #32
0
        public override void OnUpdate()
        {
            var i = -1;
            if ((int)trackedObj.index > i++)
            {
                device = SteamVR_Controller.Input((int)trackedObj.index);
                switch (menuType)
                {
                    case setMenuType.getPress:
                        var padDown = device.GetTouchUp(SteamVR_Controller.ButtonMask.ApplicationMenu);
                        if (padDown)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padDown;
                        break;
                    case setMenuType.getPressUp:
                        var padDownUp = device.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padDownUp)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padDownUp;
                        break;
                    case setMenuType.getPressDown:
                        var padDownDown = device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padDownDown)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padDownDown;
                        break;
                    case setMenuType.getTouch:
                        var padTouch = device.GetTouch(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padTouch)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padTouch;
                        break;
                    case setMenuType.getTouchUp:
                        var padTouchUp = device.GetTouchUp(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padTouchUp)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padTouchUp;
                        break;
                    case setMenuType.getTouchDown:
                        var padTouchDown = device.GetTouchDown(SteamVR_Controller.ButtonMask.ApplicationMenu);

                        if (padTouchDown)
                        {
                            Fsm.Event(sendEvent);
                        }
                        storeResult.Value = padTouchDown;
                        break;
                }
            }
        }