Ejemplo n.º 1
0
        public bool MapVrTouch(VrInput input)
        {
            switch (input)
            {
            case VrInput.Directional:
            case VrInput.Thumbstick:
                return(controller.GetAxis2D(WebXRController.Axis2DTypes.Thumbstick) != Vector2.zero);

            case VrInput.Touchpad:
                return(controller.GetAxis2D(WebXRController.Axis2DTypes.Touchpad) != Vector2.zero);

            case VrInput.Button01:
            case VrInput.Button04:
            case VrInput.Button06:
                // Pad_Left, Pad_Down, Full pad, (X,A)
                return(controller.GetButton(WebXRController.ButtonTypes.ButtonA));

            case VrInput.Button02:
            case VrInput.Button03:
            case VrInput.Button05:
                // Pad_Right, Pad_Up, Application button, (Y,B)
                return(controller.GetButton(WebXRController.ButtonTypes.ButtonB));

            case VrInput.Any:     // Adjust this later
                return(true);

            default:
                Debug.Log("This shouldn't have happened! Bad input enum " + input.ToString());
                throw new System.NotImplementedException();     // Ask De-Panther about adding a WebXRController.ButtonTypes.None
            }
        }
        private void UpdateHandAnimationState()
        {
            float handAnimationNormalizedTime = webXRController.GetButton(WebXRController.ButtonTypes.Trigger) ? 1 : webXRController.GetAxis(WebXRController.AxisTypes.Grip);

            //Set anim current state depending on grip and trigger pressure
            thisHandAnimator.Play("Take", -1, handAnimationNormalizedTime);
        }
        void Update()
        {
            controller.TryUpdateButtons();

            // Get button A(0 or 1), or Axis Trigger/Grip (0 to 1), the larger between them all, by that order
            float normalizedTime = controller.GetButton(WebXRController.ButtonTypes.ButtonA) ? 1 :
                                   Mathf.Max(controller.GetAxis(WebXRController.AxisTypes.Trigger),
                                             controller.GetAxis(WebXRController.AxisTypes.Grip));

            if (controller.GetButtonDown(WebXRController.ButtonTypes.Trigger) ||
                controller.GetButtonDown(WebXRController.ButtonTypes.Grip) ||
                controller.GetButtonDown(WebXRController.ButtonTypes.ButtonA))
            {
                Pickup();
            }

            if (controller.GetButtonUp(WebXRController.ButtonTypes.Trigger) ||
                controller.GetButtonUp(WebXRController.ButtonTypes.Grip) ||
                controller.GetButtonUp(WebXRController.ButtonTypes.ButtonA))
            {
                Drop();
            }

            // Use the controller button or axis position to manipulate the playback time for hand model.
            anim.Play("Take", -1, normalizedTime);
        }
Ejemplo n.º 4
0
        public override bool GetVrInput(VrInput input)
        {
            if (!m_IsValid)
            {
                return(false);
            }

            return(controller.GetButton(MapVrInput(input)));
        }
    void Update()
    {
        float normalizedTime = controller.GetButton("Trigger") ? 1 : controller.GetAxis("Grip");

        if (controller.GetButtonDown("Trigger") || controller.GetButtonDown("Grip"))
        {
            Pickup();
        }

        if (controller.GetButtonUp("Trigger") || controller.GetButtonUp("Grip"))
        {
            Drop();
        }

        // Use the controller button or axis position to manipulate the playback time for hand model.
        anim.Play("Take", -1, normalizedTime);
    }
        private void Update()
        {
            if (!controllerVisible && !handJointsVisible)
            {
                return;
            }

            // Get button A(0 or 1), or Axis Trigger/Grip (0 to 1), the larger between them all, by that order
            float normalizedTime = controller.GetButton(WebXRController.ButtonTypes.ButtonA) ? 1 :
                                   Mathf.Max(controller.GetAxis(WebXRController.AxisTypes.Trigger),
                                             controller.GetAxis(WebXRController.AxisTypes.Grip));

            if (controller.GetButtonDown(WebXRController.ButtonTypes.Trigger) ||
                controller.GetButtonDown(WebXRController.ButtonTypes.Grip) ||
                controller.GetButtonDown(WebXRController.ButtonTypes.ButtonA))
            {
                Pickup();
            }

            if (controller.GetButtonUp(WebXRController.ButtonTypes.Trigger) ||
                controller.GetButtonUp(WebXRController.ButtonTypes.Grip) ||
                controller.GetButtonUp(WebXRController.ButtonTypes.ButtonA))
            {
                Drop();
            }

            currentVelocity = (transform.position - previousPos) / Time.deltaTime;
            previousPos     = transform.position;

#if WEBXR_INPUT_PROFILES
            if (loadedModel && useInputProfile)
            {
                UpdateModelInput();
                return;
            }
#endif

            // Use the controller button or axis position to manipulate the playback time for hand model.
            if (hasAnimator)
            {
                animator.Play(animationStateName, -1, normalizedTime);
            }
        }
 private void GetXRButtonStatus(string buttonName, ref XRButtonStatus buttonStatus)
 {
     if (controller.GetButtonDown(buttonName))
     {
         buttonStatus = XRButtonStatus.ButtonDown;
     }
     else if (controller.GetButtonUp(buttonName))
     {
         buttonStatus = XRButtonStatus.ButtonUp;
     }
     else if (controller.GetButton(buttonName))
     {
         buttonStatus = XRButtonStatus.isDown;
     }
     else
     {
         buttonStatus = XRButtonStatus.None;
     }
 }
Ejemplo n.º 8
0
 void Update()
 {
     if (!allowShooting)
     {
         return;
     }
     ray = mainCamera.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, out hit))
     {
         particleLouncherPivot.LookAt(hit.point);
         if (Input.GetMouseButton(0) || webXRController.GetButton("Trigger"))
         {
             particleLouncher.isShooting = true;
         }
         else
         {
             particleLouncher.isShooting = false;
         }
     }
 }
Ejemplo n.º 9
0
    void Update()
    {
        if (ballRigidBody && controller.GetButtonDown(C.grip))
        {
            ballRigidBody.AddForce(transform.forward.normalized * launchForce);
            Drop();
            return;
        }

        if (controller.GetButtonDown(C.trigger))
        {
            Pickup();
            return;
        }

        if (controller.GetButtonUp(C.trigger))
        {
            Drop();
            return;
        }

        if (controller.GetButtonDown(C.grip))
        {
            beam.on = true;
            return;
        }

        if (controller.GetButtonUp(C.grip))
        {
            beam.PullObject();
            return;
        }

        // Use the controller button or axis position to manipulate the playback time for hand model.
        var normalizedTime = controller.GetButton(C.trigger) ? 1 : controller.GetAxis(C.grip);
        animator.Play("Take", -1, normalizedTime);
    }
        public void OnUpdate(float realTime)
        {
            #region Hand Velocity Information
            //to enable throwing physics objects
            if (currentTransform)
            {
                if (currentRB)
                {
                    newPos = thisTransform.position;
                    var dif = newPos - oldPos;
                    velocity = dif / Time.deltaTime;
                    oldPos   = newPos;
                }
            }
            #endregion

            #region Hand Input Calls

            float hand_Anim_NormalizedTime = webXRController.GetButton(WebXRController.ButtonTypes.Trigger) ? 1 : webXRController.GetAxis(WebXRController.AxisTypes.Grip);

            //Set anim current state depending on grip and trigger pressure
            thisAnimCont.Play("Take", -1, hand_Anim_NormalizedTime);

            if (webXRController.GetButtonDown(WebXRController.ButtonTypes.Grip))
            {
                onGripButtonDown.Invoke();
                PickUp();


                if (firstControllerInteraction == this)
                {
                    DoubleTapState.Instance.leftHandGripPressed = true;
                }

                if (secondControllerInteraction == this)
                {
                    DoubleTapState.Instance.rightHandGripPressed = true;
                }

                if (DoubleTapState.Instance.leftHandGripPressed == true && DoubleTapState.Instance.rightHandGripPressed == true)
                {
                    DoubleTapState.Instance.OnDoubleGripStateOn?.Invoke();
                }
            }

            if (webXRController.GetButtonUp(WebXRController.ButtonTypes.Grip))
            {
                onGripButtonUp.Invoke();
                Drop();


                if (firstControllerInteraction == this)
                {
                    DoubleTapState.Instance.leftHandGripPressed = false;
                }

                if (secondControllerInteraction == this)
                {
                    DoubleTapState.Instance.rightHandGripPressed = false;
                }

                DoubleTapState.Instance.OnDoubleGripStateOff?.Invoke();
            }

            if (webXRController.GetButtonUp(WebXRController.ButtonTypes.Trigger))
            {
                onTriggerButtonUp.Invoke();

                //set the state of our current controller press
                if (firstControllerInteraction == this)
                {
                    DoubleTapState.Instance.leftHandTriggerPressed = false;
                }

                if (secondControllerInteraction == this)
                {
                    DoubleTapState.Instance.rightHandTriggerPressed = false;
                }


                DoubleTapState.Instance.OnDoubleTriggerStateOff?.Invoke();
                //if (DoubleTapState.Instance.leftHandTrigger == false && DoubleTapState.Instance.rightHandTrigger == false)
                //    DoubleTapState.Instance.OnDoubleGripStateOff?.Invoke();
                //.gripTicks = -1;
            }

            if (webXRController.GetButtonDown(WebXRController.ButtonTypes.Trigger))
            {
                onTriggerButtonDown.Invoke();


                if (firstControllerInteraction == this)
                {
                    DoubleTapState.Instance.leftHandTriggerPressed = true;
                }

                if (secondControllerInteraction == this)
                {
                    DoubleTapState.Instance.rightHandTriggerPressed = true;
                }

                if (DoubleTapState.Instance.leftHandTriggerPressed == true && DoubleTapState.Instance.rightHandTriggerPressed == true)
                {
                    DoubleTapState.Instance.OnDoubleTriggerStateOn?.Invoke();
                }
            }

            //A button - primarybutton
            if (webXRController.GetButtonDown(WebXRController.ButtonTypes.ButtonA))
            {
                onPrimaryButtonDown.Invoke();
            }

            if (webXRController.GetButtonUp(WebXRController.ButtonTypes.ButtonA))
            {
                onPrimaryButtonUp.Invoke();
            }

            if (webXRController.GetButtonDown(WebXRController.ButtonTypes.ButtonB))
            {
                onSecondaryButtonDown.Invoke();
            }

            if (webXRController.GetButtonUp(WebXRController.ButtonTypes.ButtonB))
            {
                onSecondaryButtonUp.Invoke();
            }

            float horAxis = webXRController.GetAxisIndexValue(2); //webXRController.GetAxis("ThumbstickX");
            float verAxis = webXRController.GetAxisIndexValue(3); //webXRController.GetAxis("ThumbstickY");

            //Reset Horizontal Flick
            if (horAxis >= -0.5f && horAxis <= 0.5f)
            {
                isHorAxisReset = true;
            }

            //Left flick
            if (horAxis < -0.5f && isHorAxisReset)
            {
                isHorAxisReset = false;
                onRightFlick.Invoke();
            }

            //Right flick
            if (horAxis > 0.5f && isHorAxisReset)
            {
                isHorAxisReset = false;
                onLeftFlick.Invoke();
            }

            //Reset Vertical Flick
            if (verAxis >= -0.5f && verAxis <= 0.5f)
            {
                isVerAxisReset = true;
            }

            if (verAxis < -0.5f && isVerAxisReset)
            {
                isVerAxisReset = false;
                onDownFlick.Invoke();
            }

            if (verAxis > 0.5f && isVerAxisReset)
            {
                isVerAxisReset = false;
                onUpFlick.Invoke();
            }

            if (webXRController.GetButtonDown(WebXRController.ButtonTypes.Thumbstick))
            {
                onThumbstickButtonDown.Invoke();
            }

            if (webXRController.GetButtonUp(WebXRController.ButtonTypes.Thumbstick))
            {
                onThumbstickButtonUp.Invoke();
            }
            #endregion
        }
Ejemplo n.º 11
0
 void Update()
 {
     particleLouncher.isShooting = webXRController.GetButton(buttonName);
 }
Ejemplo n.º 12
0
 // Update is called once per frame
 void Update()
 {
     Receive(controller.GetButton(WebXRController.ButtonTypes.Trigger));
 }