示例#1
0
        public void _UpdateHands(Vox.Hands.HandController voxHands, SteamVR_Input_Sources source)
        {
            if (selectionHands.Count == 0)
            {
                return;
            }

            var position      = SteamVR_Input.GetVector2("default", "Selection", source);
            var elementsCount = selectionHands.Count;
            int index         = 0;

            if (position != Vector2.zero)
            {
                var angle = (Vector2.SignedAngle(Vector2.down, position) + 180) / 360;
                index = Mathf.FloorToInt(((angle * elementsCount) + 0.5f) % elementsCount);
            }

            //var blendShapeKey = new BlendShapeKey (element.blendShapeName);
            var targetWeight = SteamVR_Input.GetSingle("default", "GrabGrip", source);

            //var targetWeight = element.GetValue (HandType);

            //element.weight += (targetWeight - element.weight) * Time.deltaTime * element.speed;
            //element.weight = Mathf.Clamp01 (element.weight);

            voxHands.SetHandPose(selectionHands[index].presetName, targetWeight);
        }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        gameObject.transform.rotation = controller.rotation;
        gameObject.transform.Rotate(-20.0f, -150.0f, -90.0f);

        if (controller.position.y > maxY)
        {
            maxY = controller.localPosition.y;
        }
        if (controller.position.y < minY)
        {
            minY = controller.localPosition.y;
        }

        if (maxY - minY > 0.2f)
        {
            flying = true;
        }
        else
        {
            flying = false;
        }

        touchpadAxis = SteamVR_Input.GetVector2("Default", "chooseDialog", steamVR_Behaviour_Vector2.inputSource);
        if (talkable)
        {
            if (touchpadAxis.y > 0.5)
            {
                dialog1.color = Color.yellow;
                dialog2.color = Color.white;
                dialog3.color = Color.white;
                if (SteamVR_Input.GetStateDown("default", "clickDialog", steamVR_Behaviour_Boolean.inputSource))
                {
                    dialog = 1;
                }
            }
            else if (touchpadAxis.y < -0.5)
            {
                dialog1.color = Color.white;
                dialog2.color = Color.white;
                dialog3.color = Color.yellow;
                if (SteamVR_Input.GetStateDown("default", "clickDialog", steamVR_Behaviour_Boolean.inputSource))
                {
                    dialog = 3;
                }
            }
            else
            {
                dialog1.color = Color.white;
                dialog2.color = Color.yellow;
                dialog3.color = Color.white;
                if (SteamVR_Input.GetStateDown("default", "clickDialog", steamVR_Behaviour_Boolean.inputSource))
                {
                    dialog = 2;
                }
            }
        }
    }
示例#3
0
 float GetInputValue()
 {
     if (VRIsActive)
     {
         Vector2 trackpadPos = SteamVR_Input.GetVector2("Trackpad", SteamVR_Input_Sources.LeftHand);
         return(trackpadPos.x * pageTurnRate);
     }
     else
     {
         return((Input.mousePosition.x / Screen.width) * pageTurnRate * 2);
     }
 }
示例#4
0
        // Update is called once per frame
        void Update()
        {
            if (gun == null)
            {
                gun = FindObjectOfType <GunManager>();
            }
            isShoot = SteamVR_Input.GetStateUp("ShootGun", SteamVR_Input_Sources.LeftHand);
            if (isShoot)
            {
                gun.ShootGun();
            }

            locomotionVector = SteamVR_Input.GetVector2("Locomotion", SteamVR_Input_Sources.LeftHand);
            locomotion.supplyLocomotionVector(locomotionVector);
        }
    //Mueve al jugador
    void Movement()
    {
        //Consigue la posicion del player
        trackpadValues = SteamVR_Input.GetVector2("dPad", hand.handType, true);

        if (trackpadValues.x > trackpadTolerance)
        {
            speed.x = strafeSpeed;
        }
        else if (trackpadValues.x < -trackpadTolerance)
        {
            speed.x = -strafeSpeed;
        }
        if (trackpadValues.y > trackpadTolerance)
        {
            speed.z = forwardSpeed;
        }
        else if (trackpadValues.y < -trackpadTolerance)
        {
            speed.z = -backSpeed;
        }
        if (trackpadValues.y <= trackpadTolerance && trackpadValues.y >= -trackpadTolerance && trackpadValues.x <= trackpadTolerance && trackpadValues.x >= -trackpadTolerance)
        {
            speed = Vector3.zero;
        }

        //Tengo retraso nocturno alguien que haga bien el movimiento xd ya recibe los valores del control xd o yo mas al rato :p
        if (useRBody)
        {
            if (speed != Vector3.zero)
            {
                rBody.AddForce(Quaternion.Euler(Vector3.up * vrCamera.transform.rotation.eulerAngles.y) * speed, ForceMode.Impulse);
                //rBody.AddForce(new Vector3(speed.x, 0, speed.z), ForceMode.Impulse);
            }
            else
            {
                rBody.velocity = Vector3.zero;
            }
        }
        else
        {
            parent.transform.position += Quaternion.Euler(Vector3.up * vrCamera.transform.rotation.eulerAngles.y) * speed;
        }
    }
示例#6
0
    //Controller actions
    #region
    void ToolControllerAction()
    {
        toolTrackPos  = SteamVR_Input.GetVector2(trackPadPos_tool, SteamVR_Input_Sources.Any, true);
        toolTrackDown = SteamVR_Input.GetStateDown(trackPadClick_tool, SteamVR_Input_Sources.Any, true);
        toolTrack     = SteamVR_Input.GetState(trackPadClick_tool, SteamVR_Input_Sources.Any, true);

        if (SteamVR_Input.GetStateDown(triggerClick_tool, SteamVR_Input_Sources.Any, true))
        {
            toolSet.TriggerDown();
        }
        else if (toolTrackDown && toolTrackPos.y < 0.5f && toolTrackPos.y > -0.5f)
        {
            if (toolTrackPos.x < -0.5f)
            {
                toolSet.PadRight(Button.release);
                toolSet.PadLeft(Button.press);
                toolPressed = true;
            }
            else if (toolTrackPos.x > 0.5f)
            {
                toolSet.PadLeft(Button.release);
                toolSet.PadRight(Button.press);
                toolPressed = true;
            }
        }
        else if (toolTrackDown && toolTrackPos.x < 0.5f && toolTrackPos.x > -0.5f)
        {
            if (toolTrackPos.y < -0.5f)
            {
                toolSet.PadDown();
            }
            else if (toolTrackPos.y > 0.5f)
            {
                toolSet.PadUp();
            }
        }

        if (!toolTrack && toolPressed)
        {
            toolSet.PadLeft(Button.release);
            toolSet.PadRight(Button.release);
            toolPressed = false;
        }
    }
示例#7
0
    void SteeringControllerAction()
    {
        steeringTrackPos  = SteamVR_Input.GetVector2(trackPadPos_steering, SteamVR_Input_Sources.Any, true);
        steeringTrackDown = SteamVR_Input.GetStateDown(trackPadClick_steering, SteamVR_Input_Sources.Any, true);
        steeringTrack     = SteamVR_Input.GetState(trackPadClick_steering, SteamVR_Input_Sources.Any, true);

        if (SteamVR_Input.GetStateDown(triggerClick_steering, SteamVR_Input_Sources.Any, true))
        {
            behaviourTool.Engage();
            steeringTriggerDown = true;
        }
        else if (steeringTrackDown && steeringTrackPos.y < 0.5f && steeringTrackPos.y > -0.5f)
        {
            if (steeringTrackPos.x < -0.5f)
            {
                behaviourTool.ChangePart(PlacementBehaviour.ToolsetControls.Left);
            }
            else if (steeringTrackPos.x > 0.5f)
            {
                behaviourTool.ChangePart(PlacementBehaviour.ToolsetControls.Right);
            }
        }
        else if (steeringTrack && steeringTrackPos.x < 0.5f && steeringTrackPos.x > -0.5f)
        {
            if (steeringTrackPos.y < -0.5f)
            {
                behaviourTool.ScrollPart(PlacementBehaviour.ToolsetControls.Down);
            }
            else if (steeringTrackPos.y > 0.5f)
            {
                behaviourTool.ScrollPart(PlacementBehaviour.ToolsetControls.Up);
            }
        }


        if (!SteamVR_Input.GetState(triggerClick_steering, SteamVR_Input_Sources.Any, true) && steeringTriggerDown)
        {
            behaviourTool.DisEngage();
            steeringTriggerDown = false;
        }
    }