public void SetSliderExtents()
    {
        HapticCapabilities caps   = new HapticCapabilities();
        InputDevice        device = InputDevices.GetDeviceAtXRNode(node);

        if (device == null ||
            !device.TryGetHapticCapabilities(out caps) ||
            !caps.supportsImpulse
            )
        {
            return;
        }

        switch (driveType)
        {
        case DriveType.Amplitude:
            m_Slider.maxValue = 1f;
            m_Slider.minValue = 0;
            break;

        case DriveType.Frequency:
            m_Slider.maxValue = 1f;
            m_Slider.minValue = 0;
            break;

        case DriveType.Duration:
            m_Slider.maxValue = 10f;
            m_Slider.minValue = 0;
            break;
        }

        m_Slider.value = m_Slider.maxValue;
    }
    public override bool TryGetPoseFromProvider(out Pose output)
    {
        var        device   = InputDevices.GetDeviceAtXRNode(DeviceToTrack);
        Vector3    position = Vector3.zero;
        Quaternion rotation = Quaternion.identity;
        DateTime   time     = new DateTime();

        time = DateTime.Now;
        time = time.AddMilliseconds(-TimeBackwards);

        if (device.TryGetFeatureValue(CommonUsages.deviceRotation, time, out rotation))
        {
            Debug.Log("Frame " + Time.frameCount + " " + DeviceToTrack + " rotation at time " + DateTime.Now.Millisecond + " - " + TimeBackwards + "= (" + time.Millisecond + ") is " + rotation.w + ", " + rotation.x + ", " + rotation.y + ", " + rotation.z);

            device.TryGetFeatureValue(CommonUsages.devicePosition, time, out position);
            output.position = position;
            output.rotation = rotation;
            return(true);
        }
        else
        {
            output = Pose.identity;
            return(false);
        }
    }
Пример #3
0
 /// <summary>
 /// This override is called when the VRTK SDK is loaded. This is used here to fetch the Input Device handle for the appropriate controller.
 /// </summary>
 protected override void Instance_LoadedSetupChanged(VRTK_SDKManager sender, VRTK_SDKManager.LoadedSetupChangeEventArgs e)
 {
     if (e.currentSetup.controllerSDKInfo.type == hapticSystemInfo.ConnectedSDKType)
     {
         hapticDevice = InputDevices.GetDeviceAtXRNode(handNodeType);
     }
 }
Пример #4
0
    public Vector3 GetHandVelocity()
    {
        Vector3 outVelocity;

        InputDevices.GetDeviceAtXRNode(handInputDevice).TryGetFeatureValue(UnityEngine.XR.CommonUsages.deviceVelocity, out outVelocity);
        return(outVelocity);
    }
    // Start is called before the first frame update
    void Start()
    {
        List <InputDevice> devices = new List <InputDevice>();

        InputDevices.GetDevicesWithCharacteristics(controllerCharacteristics, devices);
        deviceR = InputDevices.GetDeviceAtXRNode(rightController);
    }
Пример #6
0
        // Update is called once per frame
        void FixedUpdate()
        {
            // if(leftControllerDevice == null)
            _walkControllerDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
            //  if (rightControllerDevice == null)
            _turnControllerDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);

            GameObject g;

            if (_lHandTransform == null)
            {
                g = GameObject.Find("LeftHand");
                if (g != null)
                {
                    _lHandTransform = g.transform;
                }
            }
            if (_rHandTransform == null)
            {
                g = GameObject.Find("RightHand");
                if (g != null)
                {
                    _rHandTransform = g.transform;
                }
            }
            if (!(_rHandTransform == null) && !(_lHandTransform == null))
            {
                SetColliderPosition();
                //AddRocketForce();
                //AddControllerRotation();
                AddControllerRotationJoystick();
                AddWalkingForce();
            }
        }
Пример #7
0
    private void Update()
    {
        _head      = InputDevices.GetDeviceAtXRNode(XRNode.Head);
        _leftHand  = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
        _rightHand = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);

        if (Input.GetKey(KeyCode.Tab))
        {
            Recenter();
        }

        var cameraTransform = Camera.main.transform;

        messagesCanvas.transform.LookAt(cameraTransform.position);
        messagesCanvas.transform.Rotate(0, 180, 0);

        _leftHand.TryGetFeatureValue(CommonUsages.deviceRotation, out var leftHandRotation);
        _leftHand.TryGetFeatureValue(CommonUsages.devicePosition, out var leftHandPosition);
        _rightHand.TryGetFeatureValue(CommonUsages.deviceRotation, out var rightHandRotation);
        _rightHand.TryGetFeatureValue(CommonUsages.devicePosition, out var rightHandPosition);

        movementStick.transform.localRotation = rightHandRotation;
        movementStick.transform.localPosition = rightHandPosition;
        rotationStick.transform.localRotation = leftHandRotation;
        rotationStick.transform.localPosition = leftHandPosition;
    }
    public void VerifyXRDevice_userPresence_isPresent()
    {
#if XR_SDK
        var mockHmd = "MockHMDXRSDK";
#else
        var mockHmd = "MockHMD";
#endif //XR_SDK

        Debug.Log("Settings.EnabledXrTarget is " + Settings.EnabledXrTarget);

        if (Settings.EnabledXrTarget == mockHmd || Application.isEditor)
        {
            var reasonString = Settings.EnabledXrTarget == mockHmd ? $"EnabledXrTarget == {mockHmd}" : "Test is running in the Editor";

            Assert.Ignore("{0}: UserPresenceState.Present will always be false. Ignoring", reasonString);
        }
        else
        {
#if  XR_SDK
            var device = InputDevices.GetDeviceAtXRNode(XRNode.Head);
            Assert.IsTrue(device.isValid, "The userPresence is UnSupported on this device. Expected head device is InValid.");
#if UNITY_2019_3_OR_NEWER
            Assert.IsTrue(device.TryGetFeatureValue(CommonUsages.userPresence, out bool value), "The userPresence was not found or is Unknown on the head device");
#else
            Assert.IsTrue(device.TryGetFeatureValue(new InputFeatureUsage <bool>("UserPresence"), out bool value), "The userPresence is Unknown on the head device");
#endif //UNITY_2019_3_OR_NEWER
            Assert.IsTrue(value, "userPresence is Not Present on head device.");
#else
            Assert.AreEqual(XRDevice.userPresence, UserPresenceState.Present, string.Format("Not mobile platform. Expected XRDevice.userPresence to be {0}, but is {1}.", UserPresenceState.Present, XRDevice.userPresence));
#endif //XR_SDK
        }
    }
Пример #9
0
 //mouvement en grimpant
 void climb()
 {
     //chercher la velocité de la manette qui grimpe
     InputDevices.GetDeviceAtXRNode(climbingHand.controllerNode).TryGetFeatureValue(CommonUsages.deviceVelocity, out Vector3 velocity);
     //bouge le personnage avec la valeur cherchée en haut
     character.Move(transform.rotation * -velocity * Time.fixedDeltaTime);
 }
Пример #10
0
 public void HapticEvent(float haptStrength)
 {
     if (this.GetComponent <OVRGrabbable>().isGrabbed)
     {
         // 1.
         InputDevice leftController   = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
         InputDevice rightController  = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
         InputDevice activeController = leftController;
         // 2.
         HapticCapabilities capabilities;
         OVRGrabber         hand = this.gameObject.GetComponent <OVRGrabbable>().grabbedBy;
         if (hand.name == "LeftHandAnchor")
         {
             activeController = leftController;
         }
         else if (hand.name == "RightHandAnchor")
         {
             activeController = rightController;
         }
         if (activeController.TryGetHapticCapabilities(out capabilities))
         {
             if (capabilities.supportsImpulse)
             {
                 uint  channel   = 0;
                 float amplitude = haptStrength;
                 float duration  = 0.1f;
                 // 3.
                 activeController.SendHapticImpulse(channel, amplitude, duration);
             }
         }
     }
 }
Пример #11
0
    private void GetDevices()
    {
        bool finished = true;

        ++tries;

        for (int i = 0; i < NODE_COUNT; ++i)
        {
            if (devices[i] == null || devices[i].name == "")
            {
                devices[i] = InputDevices.GetDeviceAtXRNode((XRNode)i);

                if (devices[i].name == "")
                {
                    finished = false;
                }
            }
        }

        if (!finished && tries < maxDeviceGetTries)
        {
            Invoke("GetDevices", 0.1f);
        }
        else if (!finished)
        {
            Invoke("GetDevices", 5f);
        }
    }
Пример #12
0
        private void FixedUpdate()
        {
            if (!xrUser.gravitation.active || (!rightController.teleportation.isActive && !leftController.teleportation.isActive))
            {
                if (climbingRam.climbingHand)
                {
                    // climbing computation
                    InputDevices.GetDeviceAtXRNode(climbingRam.climbingHand.controllerNode).TryGetFeatureValue(CommonUsages.deviceVelocity, out Vector3 velocity);
                    Move(transform.rotation * -velocity * Time.fixedDeltaTime);
                }
                else
                {
                    if (motionRam.continuousMovement)
                    {
                        if (motionRam.activeContinuousMovement.speed <= 0.1f)
                        {
                            Debug.LogWarning("Motion speed " + motionRam.activeContinuousMovement.speed + " is low");
                        }
                        Quaternion headYaw   = Quaternion.Euler(0, xrRig.cameraGameObject.transform.eulerAngles.y, 0); // rotation
                        Vector3    direction = headYaw * new Vector3(motionRam.continuousInputAxis.x, 0, motionRam.continuousInputAxis.y) * Time.deltaTime * motionRam.activeContinuousMovement.speed;
                        Move(direction);
                    }

                    if (xrUser.gravitation.active)
                    {
                        ApplyGravity();
                    }
                }
            }
            else
            {
                Debug.Log("Motion Ram is teleportation");
            }
        }
    // Update is called once per frame
    void Update()
    {
        Vector2     value;
        InputDevice device = InputDevices.GetDeviceAtXRNode(node);

        if (!InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(new InputFeatureUsage <Vector2>(usageName), out value))
        {
            return;
        }

        currentXValue = value.x;
        currentYValue = value.y;

        if (horizontalSliderComponent != null)
        {
            horizontalSliderComponent.value = value.x;
        }

        if (verticalSliderComponent != null)
        {
            verticalSliderComponent.value = value.y;
        }

        if (valueTextComponent != null)
        {
            valueTextComponent.text = string.Format("[{0},{1}]", value.x.ToString("F"), value.y.ToString("F"));
        }
    }
Пример #14
0
    void Update()
    {
        device = InputDevices.GetDeviceAtXRNode(inputSource);
        device.TryGetFeatureValue(CommonUsages.secondaryButton, out isButtonPressed);

        if (isButtonPressed)
        {
            if (isButtonHeld)
            {
                //ButtonHeldEvent.Invoke();
            }
            else
            {
                isButtonHeld = true;
                currentPuzzle.ResetPlanet();
                //ButtonDownEvent.Invoke();
            }
        }

        else
        {
            //ButtonUpEvent.Invoke();
            isButtonHeld = false;
        }
    }
Пример #15
0
    //fonction de mouvement en se tirant
    void drag()
    {
        //activer le point d'ancrage
        dragAnchor.SetActive(true);

        //chercher valeur de position de la manette
        InputDevices.GetDeviceAtXRNode(draggingHand.controllerNode).TryGetFeatureValue(CommonUsages.devicePosition, out Vector3 position);
        //position du point d'ancrage devient position de la manette
        dragAnchor.transform.position = position;

        //chercher la velocité de la manette
        InputDevices.GetDeviceAtXRNode(draggingHand.controllerNode).TryGetFeatureValue(CommonUsages.deviceVelocity, out Vector3 velocity);

        //si on ne vole pas
        if (variablesGlobales.voler == false)
        {
            //enlever la velocité en Y
            dragVelocity = new Vector3(velocity.x, 0, velocity.z);
        }
        //si on vole
        else
        {
            //on prend la velocité au complet
            dragVelocity = velocity;
            //et dire au script de mouvement qu'on n'est pas en train de tomber
            moveScript.fallingSpeed = 0;
        }

        //bouger le VRRig en avec dragVelocity
        character.Move(transform.rotation * -dragVelocity * Time.fixedDeltaTime * dragSpeed);
    }
Пример #16
0
    void Update()
    {
        bool        gripDown = false;
        InputDevice hand     = InputDevices.GetDeviceAtXRNode(handType);

        hand.TryGetFeatureValue(CommonUsages.gripButton, out gripDown);

        // 1.
        if (gripDown)                                                                                                                                            // 2.
        {
            Collider[] overlaps = Physics.OverlapSphere(transform.position, 0.2f);

            foreach (Collider c in overlaps)
            {
                GameObject other = c.gameObject;

                // 3.
                if (other.GetComponent <Grabbable>())
                {
                    if (other.gameObject.transform.parent == null)
                    {
                        other.transform.SetParent(transform);
                    }
                }
            }
        }
    }
Пример #17
0
    void Update()
    {
        bool        gripDown = false;
        InputDevice hand     = InputDevices.GetDeviceAtXRNode(handType);

        if (hand == null)
        {
            Debug.Log("hand not found");
        }
        hand.TryGetFeatureValue(CommonUsages.gripButton, out gripDown);

        if (!gripDown)
        {
            return;
        }

        Debug.Log("found grab event.");

        Collider[] overlaps = Physics.OverlapSphere(transform.position, 0.2f);

        foreach (var c in overlaps)
        {
            Debug.Log("found overlapped items.");
            GameObject other = c.gameObject;
            if (!other.GetComponent <Grabbable>())
            {
                continue;
            }
            if (other.gameObject.transform.parent == null)
            {
                other.transform.SetParent(transform);
            }
        }
    }
Пример #18
0
    void Update()
    {
        bool        gripDown = false;
        InputDevice hand     = InputDevices.GetDeviceAtXRNode(handType);

        hand.TryGetFeatureValue(CommonUsages.gripButton, out gripDown);

        // 1.
        if (gripDown)
        {
            // 2.
            Collider[] overlaps = Physics.OverlapSphere(transform.position, 0.2f);

            foreach (Collider c in overlaps)
            {
                GameObject other = c.gameObject;

                // 3.
                int grabbableLayerIndex = LayerMask.NameToLayer("Grabbable");
                if (other.layer == grabbableLayerIndex)
                {
                    ControllerHaptics haptics = GetComponentInParent <ControllerHaptics>();
                    if (haptics)
                    {
                        haptics.HapticEvent();
                    }
                    other.transform.SetParent(transform);
                }
            }
        }
    }
Пример #19
0
    void AddThrowForce()    //adds a little extra zip to thrown objects so they go farther to accomodate for gravitational forces, probably overkill
    {
        CheckActiveHand();

        switch (activeHand)
        {
        case 0:     //left hand
            InputDevice leftDevice = InputDevices.GetDeviceAtXRNode(leftHandSource);
            leftDevice.TryGetFeatureValue(CommonUsages.deviceAngularVelocity, out throwAngularVelocity);
            Vector3 tossDirL = throwForce * -throwAngularVelocity;
            this.GetComponent <Rigidbody>().AddForce(tossDirL);      //hopefully throws the object farther
            break;

        case 1:
            InputDevice rightDevice = InputDevices.GetDeviceAtXRNode(rightHandSource);
            rightDevice.TryGetFeatureValue(CommonUsages.deviceAngularVelocity, out throwAngularVelocity);
            rightDevice.TryGetFeatureValue(CommonUsages.devicePosition, out throwPosition);
            Vector3 tossDirR = throwForce * rightHand.transform.forward * throwAngularVelocity.magnitude;
            this.GetComponent <Rigidbody>().AddForce(tossDirR);      //hopefully throws the object farther
            break;

        default:
            print("error in hand ID for throwing. can't add force");
            break;
        }
    }
Пример #20
0
    bool TryGetTriggerDown()
    {
        InputDevice leftHand = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);

        if (leftHand.isValid && leftHand.TryGetFeatureValue(CommonUsages.trigger, out float leftTrigger) && leftTrigger > .85f)
        {
            if (!leftWasDown)
            {
                leftWasDown = true;
                return(true);
            }
        }
        else
        {
            leftWasDown = false;
        }
        InputDevice rightHand = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);

        if (rightHand.isValid && rightHand.TryGetFeatureValue(CommonUsages.trigger, out float rightTrigger) && rightTrigger > .85f)
        {
            if (!rightWasDown)
            {
                rightWasDown = true;
                return(true);
            }
        }
        else
        {
            rightWasDown = false;
        }
        return(false);
    }
        private void GetButtonState(XRNode node)
        {
            switch (node)
            {
            case XRNode.LeftHand:
            {
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.primary2DAxisClick, out lPrimary2DButton);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.menuButton, out lMenuButton);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.gripButton, out lGripButton);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.triggerButton, out lTriggerButton);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.primaryButton, out x);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.secondaryButton, out y);
            }
            break;

            case XRNode.RightHand:
            {
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.primary2DAxisClick, out rPrimary2DButton);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.menuButton, out rMenuButton);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.gripButton, out rGripButton);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.triggerButton, out rTriggerButton);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.primaryButton, out a);
                InputDevices.GetDeviceAtXRNode(node).TryGetFeatureValue(CommonUsages.secondaryButton, out b);
            }
            break;
            }
        }
        private void OnDidFinishEvent(MainMenuViewController mmvc, MainMenuViewController.MenuButton menuButton)
        {
            if (menuButton != MainMenuViewController.MenuButton.SoloFreePlay &&
                menuButton != MainMenuViewController.MenuButton.Party)
            {
                return;
            }
            _clickDateTime = new DateTime(0);
            _latestClick   = ControllerType.None;
            var lcvc = Resources.FindObjectsOfTypeAll <LevelCollectionViewController>().FirstOrDefault();

            if (lcvc == null)
            {
                return;
            }
            var lctv = lcvc.GetPrivateField <LevelCollectionTableView>("_levelCollectionTableView");

            if (lctv == null)
            {
                return;
            }
            _currentTableViewContent = lctv.GetPrivateField <TableView>("_tableView");
            if (_currentTableViewContent == null)
            {
                return;
            }
            Logger.log.Debug("Content table view found!");
            _genericLeftController  = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
            _genericRightController = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
            _isInitialized          = true;
        }
Пример #23
0
    private void Update()
    {
        _leftHand = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);

        _leftHand.TryGetFeatureValue(CommonUsages.trigger, out var triggerVal);

        if (triggerVal >= triggerThreshold && !_isRotating)
        {
            OnTriggerDown();
        }

        if (triggerVal < triggerThreshold && _isRotating)
        {
            OnTriggerUp();
        }

        if (!_isRotating)
        {
            return;
        }

        _leftHand.TryGetFeatureValue(CommonUsages.devicePosition, out var currentPosition);
        currentPosition += cameraContainer.transform.position;
        var tmpRotation = Quaternion.FromToRotation(_controllerReference, currentPosition);

        transform.Rotate(tmpRotation.eulerAngles, Space.World);
        _controllerReference = currentPosition;
    }
Пример #24
0
    void Start()
    {
        soundEffectPlayer = FindObjectOfType <GeneralSoundEffectPlayer>();

        activeJobPartTypes  = new List <string>();
        activeTVBoxHandlers = new List <TVBoxHandler>();

        availableTVBoxHandlers = new List <TVBoxHandler>();
        foreach (TVBoxHandler tvBoxHandler in tvBoxHandlers)
        {
            availableTVBoxHandlers.Add(tvBoxHandler);
        }

        currentConveyorSpeed = conveyorBeltHandlers[0].GetSpeed();
        foreach (ConveyorBeltHandler beltHandler in conveyorBeltHandlers)
        {
            beltHandler.SetSpeed(0);
        }

        currentSpawnTimeMultiplier = spawnManager.GetSpawnTimeMultiplier();

        currentTimeMultiplier = tvBoxHandlers[0].GetTimeMultiplier();

        mainTVComponentObjects[0].SetActive(true);
        mainTVComponentObjects[1].SetActive(false);
        mainTVComponentObjects[2].SetActive(false);

        rightControllerDevice = InputDevices.GetDeviceAtXRNode(rightController);
        leftControllerDevice  = InputDevices.GetDeviceAtXRNode(leftController);

        StartCoroutine(BackgroundMusicPlayerCo());
    }
Пример #25
0
    ///////////////////
    //private methods
    //////////////////
    private void Update()
    {
        bool        grip             = false;
        bool        trigger          = false;
        bool        primaryAxisTouch = false;
        bool        primaryTouch     = false;
        bool        secondaryTouch   = false;
        float       triggerDown      = 0;
        InputDevice hand             = InputDevices.GetDeviceAtXRNode(_HandType);

        hand.TryGetFeatureValue(CommonUsages.gripButton, out grip);
        hand.TryGetFeatureValue(CommonUsages.triggerButton, out trigger);
        hand.TryGetFeatureValue(CommonUsages.primary2DAxisTouch, out primaryAxisTouch);
        hand.TryGetFeatureValue(CommonUsages.primaryTouch, out primaryTouch);
        hand.TryGetFeatureValue(CommonUsages.secondaryTouch, out secondaryTouch);
        hand.TryGetFeatureValue(CommonUsages.trigger, out triggerDown);

        bool thumbDown = primaryAxisTouch || primaryTouch || secondaryTouch;

        float triggerTotal = 0f;

        if (trigger)
        {
            triggerTotal = 0.1f;
        }
        if (triggerDown > 0.1f)
        {
            triggerTotal = triggerDown;
        }

        _HandAnimator.SetBool("GrabbingGrip", grip);
        _HandAnimator.SetBool("ThumbUp", !thumbDown);
        _HandAnimator.SetFloat("TriggerDown", triggerTotal);
    }
Пример #26
0
        private void UpdateHandHeldDeviceIndex()
        {
            uint        leftHandedDeviceIndex = INVALID_DEVICE_INDEX;
            InputDevice leftHandedDevice      = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);

            if (leftHandedDevice.isValid)
            {
                leftHandedDeviceIndex = GetDeviceIndex(GetDeviceUID(leftHandedDevice));
            }

            uint        rightHandedDeviceIndex = INVALID_DEVICE_INDEX;
            InputDevice rightHandedDevice      = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);

            if (rightHandedDevice.isValid)
            {
                rightHandedDeviceIndex = GetDeviceIndex(GetDeviceUID(rightHandedDevice));
            }

            if (m_rightHandedDeviceIndex != rightHandedDeviceIndex || m_leftHandedDeviceIndex != leftHandedDeviceIndex)
            {
                InvokeControllerRoleChangedEvent();
            }

            m_leftHandedDeviceIndex  = leftHandedDeviceIndex;
            m_rightHandedDeviceIndex = rightHandedDeviceIndex;
        }
Пример #27
0
        public void Init(SaberType type, VRControllersInputManager vrControllersInputManager)
        {
            OVRInput.Controller oculusController;
            XRNode node;

            if (type == SaberType.SaberA)
            {
                oculusController = OVRInput.Controller.LTouch;
                node             = XRNode.LeftHand;
            }
            else
            {
                oculusController = OVRInput.Controller.RTouch;
                node             = XRNode.RightHand;
            }

            var controllerInputDevice = InputDevices.GetDeviceAtXRNode(node);

            var vrSystem = OVRInput.IsControllerConnected(oculusController) ? VRSystem.Oculus : VRSystem.SteamVR;

            var dir = _config.ThumstickDirection;

            var triggerHandler = new TriggerHandler(node, _config.TriggerThreshold, _config.ReverseTrigger);
            var gripHandler    = new GripHandler(vrSystem, oculusController, controllerInputDevice,
                                                 _config.GripThreshold, _config.ReverseGrip);
            var thumbstickAction = new ThumbstickHandler(node, _config.ThumbstickThreshold, dir, _config.ReverseThumbstick);

            _trickInputHandler.Add(_config.TriggerAction, triggerHandler);
            _trickInputHandler.Add(_config.GripAction, gripHandler);
            _trickInputHandler.Add(_config.ThumbstickAction, thumbstickAction);

            _logger.Debug("Started Input Manager using " + vrSystem);
        }
Пример #28
0
    void HandleDownUpAndClick()
    {
        InputDevice device = InputDevices.GetDeviceAtXRNode(nodeType);

        bool touched = false;

        if (device.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 touchAxis))
        {
            if (Mathf.Abs(touchAxis.x) < .5f &&
                touchAxis.y > .5f)
            {
                touched = true;
            }
        }

        //laserPointer.SetActive(touched || isPressed);

        if (device.TryGetFeatureValue(CommonUsages.primary2DAxisClick, out bool pressed))
        {
            if (touched && pressed && !isPressed)
            {
                isPressed = true;
                OnPressStart();
            }
            else if (pressed == false && isPressed)
            {
                isPressed = false;
                OnPressEnd();
            }
        }
    }
Пример #29
0
    void GrapMove()
    {
        //Hand force while gripping
        InputDevices.GetDeviceAtXRNode(grapplingHand.controllerNode).TryGetFeatureValue(CommonUsages.deviceVelocity, out Vector3 velocity);

        character.Move(transform.rotation * -velocity * Time.fixedDeltaTime);
    }
Пример #30
0
        void FixedUpdate()
        {
            collider.center = new Vector3(this.transform.InverseTransformPoint(head.position).x, 0, this.transform.InverseTransformPoint(head.position).z);

            InputDevice leftDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
            if (leftDevice.isValid)
            {
                // Move
                leftDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 axis);
                Vector3 moveDirection = Quaternion.Euler(0, head.transform.rotation.eulerAngles.y, 0) * new Vector3(axis.x, 0, axis.y);
                moveDirection *= moveSpeed;
                if (moveDirection.magnitude < 0.1f) moveDirection = Vector3.zero;
                rigidbody.velocity = new Vector3(moveDirection.x, rigidbody.velocity.y, moveDirection.z);
            }

            InputDevice rightDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
            if (rightDevice.isValid)
            {
                // Turn
                rightDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 axis);
                if (axis.x > 0.1f || axis.x < -0.1f) this.transform.RotateAround(head.position, Vector3.up, axis.x * turnSpeed);

                // Jump
                rightDevice.TryGetFeatureValue(CommonUsages.primary2DAxisClick, out bool axisClick);
                rightDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool buttonClick);
                if (axisClick || buttonClick)
                {
                    rigidbody.AddForce(new Vector3(0, jumpForce, 0), ForceMode.Impulse);
                }
            }
        }