Exemplo n.º 1
0
        void GetMovementInputs(VRTK_ControllerEvents movement, VRTK_ControllerEvents rotation)
        {
            if (rotationX == 0 && (rotation.GetTouchpadAxis().x < -0.7f || rotation.GetTouchpadAxis().x < 0.7f))
            {
                //playRotationSound = true;
            }
            else
            {
                //playRotationSound = false;
            }

            if (movement.touchpadPressed)
            {
                sprinting = !sprinting;
            }

            movementX = movement.GetTouchpadAxis().x;
            movementY = movement.GetTouchpadAxis().y;
            rotationX = rotation.GetTouchpadAxis().x;
            rotationY = rotation.GetTouchpadAxis().y;

            if (Mathf.Abs(movementX) > deadzone)
            {
                horizontal = movement.GetTouchpadAxis().x *speed;
            }
            else
            {
                horizontal = 0;
            }

            if (Mathf.Abs(movementY) > deadzone)
            {
                fwd = movement.GetTouchpadAxis().y *speed;
            }
            else
            {
                fwd = 0;
            }

            //If we are sprinting, multiply speeds by 1.4f;
            fwd        *= sprinting == true ? 1.4f : 1;
            horizontal *= sprinting == true ? 1.4f : 1;

            if (Mathf.Abs(rotationX) > deadzone)
            {
                cameraRig.RotateAround(new Vector3(head.position.x, 0, head.position.z), Vector3.up, rotationX * rotationSpeed * Time.deltaTime);
            }

            //We only want the player to jump on a positive Y-axis movement
            if (rotationY > deadzone)
            {
                attemptJump = true;
            }
            else
            {
                attemptJump = false;
            }
        }
 public void StartTracking()
 {
     if (displayUI.showBuildings)
     {
         trackingPosition = true;
         position         = events.GetTouchpadAxis().x;
     }
     else if (!displayUI.showBuildings)
     {
         trackingPosition = true;
         position         = events.GetTouchpadAxis().x;
     }
 }
    private void Update()
    {
        if (m_playArea != null)
        {
            float inputValue = 0;

            switch (button)
            {
            case Button.TouchPad:
                inputValue = m_controllerEvents.touchpadPressed ? (m_controllerEvents.GetTouchpadAxis().y > 0 ? 1 : -1) : 0;
                break;

            case Button.Trigger:
                inputValue = m_controllerEvents.GetTriggerAxis();
                if (inputValue < inputDeadZone)
                {
                    inputValue = 0;
                }
                break;
            }

            if (inputValue != 0)
            {
                inputValue += inputValue * observedObject.observerAltitude * altitudeMultiplier;

                observedObject.observerPosition += (Mathf.Pow(inputValue + 1, speedPow) - 1) * speedMultiplier * Time.deltaTime * observedObject.WorldToObservedDirection(transform.forward);
            }
        }
    }
Exemplo n.º 4
0
    private void Update()
    {
        if (m_headset != null && m_playArea != null)
        {
            float inputValue = m_controllerEvents.touchpadPressed ? (m_controllerEvents.GetTouchpadAxis().y > 0 ? 1 : -1) : 0;

            if (inputValue != 0)
            {
                inputValue *= m_controllerEvents.GetTriggerAxis() > 0.5f ? brakeMultiplier : 1;
                inputValue += inputValue * (m_headset.position.y - groundHeight) * altitudeMultiplier;
                inputValue  = Mathf.Pow(inputValue + 1, speedPow) - 1;
                Vector3 dir = transform.forward;

                Vector3 diff = inputValue * speedMultiplier * Time.deltaTime * dir;
                Vector3 pos  = m_playArea.position;

                pos += diff;

                if (diff != Vector3.zero)
                {
                    pos.y = Mathf.Clamp(pos.y, clampHeightMin, clampHeightMax);
                }

                m_playArea.position = pos;
            }
        }
    }
Exemplo n.º 5
0
    // Update is called once per frame
    void Update()
    {
        Vector3 moveAmount = Time.deltaTime * ((controllerEvents.GetTouchpadAxis().x *movementSpeed *cameraHeadObject.transform.right) + (controllerEvents.GetTouchpadAxis().y *movementSpeed *cameraHeadObject.transform.forward));

        moveAmount.y        = 0;
        transform.position += moveAmount;        //Debug.Log();
    }
Exemplo n.º 6
0
    /*
     * private void OnEnable()
     * {
     *  controller = GetComponent<VRTK_ControllerEvents>();
     *  controller.GripPressed -= TogglePause;
     *  controller.GripPressed += TogglePause;
     *  controller.TriggerClicked -= HandleTriggerClick;
     *  controller.TriggerClicked += HandleTriggerClick;
     *  controller.TriggerUnclicked -= HandleTriggerUnclick;
     *  controller.TriggerUnclicked += HandleTriggerUnclick;
     *
     *  pointer = GetComponent<VRTK_Pointer>();
     *  pointer.DestinationMarkerEnter -= HandlePointerEnter;
     *  pointer.DestinationMarkerEnter += HandlePointerEnter;
     *  pointer.DestinationMarkerExit -= HandlePointerExit;
     *  pointer.DestinationMarkerExit += HandlePointerExit;
     * }
     */

    private void Update()
    {
        if (mode == ControllerMode.Teleport && padTouched)
        {
            float t = controller.GetTouchpadAxis().y;
            teleporter.maxDist = Mathf.Clamp(teleporter.maxDist + (t - padTouchY) * 4, 1, 11);
            padTouchY          = t;
        }
    }
    private void TouchpadPressed(object sender, ControllerInteractionEventArgs e)
    {
        if (controllerEvents.GetTouchpadAxis().y <= touchpadDown)
        {
            if (GetInsertedMag() != null)
            {
                DetachObject(GetInsertedMag(), magEjectPoint);
            }
        }

        if (controllerEvents.GetTouchpadAxis().y >= touchpadUp)
        {
            if (slideControl != null && !slideControl.IsDefaultPos() && !triggerHold)
            {
                slideControl.SetPosition(0);
            }
        }
    }
Exemplo n.º 8
0
 bool TopButton()
 {
     if (events.GetTouchpadAxis().y > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 9
0
 void SetForward()
 {
     if (events.GetTouchpadAxis().y > 0)
     {
         forward = 1;
     }
     else
     {
         forward = -1;
     }
 }
    // Update is called once per frame
    void Update()
    {
        Vector2 axisChange = contrlEvents.GetTouchpadAxis();
        //Debug.Log("This is angle: " + contrlEvents.GetTouchpadAxisAngle());
        float dirMagnitude = axisChange.SqrMagnitude();

        // to go forward
        if ((contrlEvents.GetTouchpadAxisAngle() < 45f || contrlEvents.GetTouchpadAxisAngle() > 315f) &&
            contrlEvents.GetTouchpadAxisAngle() != 90f)
        {
            //Debug.Log("This is the mf magnitude: " + dirMagnitude);

            Vector3 dir = transform.forward;

            //Debug.Log("This is the mf direction: " + dir);
            if (dir.y >= 0)
            {
                dir.y -= .5f;
            }
            cameraRig.transform.position += (dir * dirMagnitude * .2f);
        }

        // to rotate right
        else if ((contrlEvents.GetTouchpadAxisAngle() < 135f && contrlEvents.GetTouchpadAxisAngle() >= 45f) &&
                 contrlEvents.GetTouchpadAxisAngle() != 90f)
        {
            //Debug.Log("This is the angle: " + contrlEvents.GetTouchpadAxisAngle());
            cameraRig.transform.Rotate(Vector3.up * dirMagnitude);
        }

        // to rotate left
        else if ((contrlEvents.GetTouchpadAxisAngle() > 225f && contrlEvents.GetTouchpadAxisAngle() <= 315f) &&
                 contrlEvents.GetTouchpadAxisAngle() != 90f)
        {
            //Debug.Log("This is the angle: " + contrlEvents.GetTouchpadAxisAngle());
            cameraRig.transform.Rotate(Vector3.down * dirMagnitude);
        }

        // to go backward
        else if ((contrlEvents.GetTouchpadAxisAngle() > 135f && contrlEvents.GetTouchpadAxisAngle() <= 225f) &&
                 contrlEvents.GetTouchpadAxisAngle() != 90f)
        {
            Vector3 dir = transform.forward;

            //Debug.Log("This is the mf direction: " + -dir);
            if (dir.y >= 0)
            {
                dir.y -= .5f;
            }
            cameraRig.transform.position += (-dir * dirMagnitude * .2f);
        }
    }
Exemplo n.º 11
0
    private void UpdateCreatureLocation()
    {
        Vector2 touchpadAxis = controller_Event.GetTouchpadAxis();

        if (touchpadAxis.x > touchpadAxis.y && touchpadAxis.x < -touchpadAxis.y)
        {
            currentTractableObject.UpdateCreatureDistance(-1);
        }
        else if (touchpadAxis.x < touchpadAxis.y && touchpadAxis.x > -touchpadAxis.y)
        {
            currentTractableObject.UpdateCreatureDistance(1);
        }
    }
Exemplo n.º 12
0
    /// <summary>
    /// the update to update everything relating to things like touchpad amount and the linerender positioning.
    /// </summary>
    void Update()
    {
        if (this != null && this.gameObject != null && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 0 && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 1 && SceneManager.GetActiveScene().buildIndex != 5 && SceneManager.GetActiveScene().buildIndex != 6)
        {
            revertcountdown--;
            if (revertcountdown == 0)
            {
                lineren.material = startmat;
            }
            if (vrtkcontrolevents == null)
            {
                vrtkcontrolevents = GetComponent <VRTK_ControllerEvents>();
            }
            touchpadamount = vrtkcontrolevents.GetTouchpadAxis().y;
            if (resizing.transform.localScale.x != 1)
            {
                lineren.startWidth = 0.002f * resizing.transform.lossyScale.x;
                lineren.endWidth   = 0.002f * resizing.transform.lossyScale.x;
            }
            resizing.speed = (lefthandscriptl.touchpadamount * 5) + 0.5f;
            if (triggerdown)
            {
                resizing.StickInput(transform.parent.localRotation);
            }
            if ((touchpadamount < -0.05f || touchpadamount > 0.05f) && touchpadDown == false)
            {
                if (resizing.WaspPos != null && resizing.WaspPos.GetActive() == false)
                {
                    lineren.enabled = true;
                }
            }
            else if (maincon == null || maincon.hitobj == null)
            {
                lineren.enabled = false;
            }
            if (touchpadamount > -0.05f && touchpadamount < 0.05f && ConeSmall.GetActive() == true)
            {
                ConeSmall.SetActive(false);
            }
            if (lineren.enabled == true)
            {
                setlinerenpos();
            }


            if (ConeSmall.GetActive() == true)
            {
                lineren.enabled = false;
            }
        }
    }
Exemplo n.º 13
0
    private void UpdateTimeline()
    {
        bool timelineTrigger = (LeftControllerEvents.GetTriggerAxis() == 1) ? true : false;

        //bool timelineTrigger = OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.LTouch);
        TimelineScript.ActiveTimeline = timelineTrigger;

        float leftThumbstick  = LeftControllerEvents.GetTouchpadAxis().x / 1000;
        float rightThumbstick = RightControllerEvents.GetTouchpadAxis().x / 1000;

        //float leftThumbstick = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).x / 1000;
        //float rightThumbstick = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick).x / 1000;
        MainScript.Time = Mathf.Clamp01(leftThumbstick + rightThumbstick + MainScript.Time);
    }
Exemplo n.º 14
0
    ControllerPose GetControllerPose(VRTK_ControllerEvents controller)
    {
        ovrAvatarButton buttons = 0;

        //if (OVRInput.Get(OVRInput.Button.One, controller)) buttons |= ovrAvatarButton.One;
        //if (OVRInput.Get(OVRInput.Button.Two, controller)) buttons |= ovrAvatarButton.Two;
        if (controller.startMenuPressed)
        {
            buttons |= ovrAvatarButton.Three;
        }
        if (controller.touchpadPressed)
        {
            buttons |= ovrAvatarButton.Joystick;
        }

        ovrAvatarTouch touches = 0;

        //if (OVRInput.Get(OVRInput.Touch.One, controller)) touches |= ovrAvatarTouch.One;
        //if (OVRInput.Get(OVRInput.Touch.Two, controller)) touches |= ovrAvatarTouch.Two;
        //if (controller.touchpadPressed) touches |= ovrAvatarTouch.Joystick;
        //if (OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, controller)) touches |= ovrAvatarTouch.ThumbRest;
        if (controller.triggerPressed)
        {
            touches |= ovrAvatarTouch.Index;
        }
        if (controller.gripPressed)
        {
            touches |= ovrAvatarTouch.Joystick;
        }
        if (controller.touchpadPressed)
        {
            touches |= ovrAvatarTouch.Pointing;
        }
        if (controller.triggerPressed && controller.gripPressed)
        {
            touches = ovrAvatarTouch.ThumbUp;
        }
        //if (!OVRInput.Get(OVRInput.NearTouch.PrimaryThumbButtons, controller)) touches |= ovrAvatarTouch.ThumbUp;

        return(new ControllerPose
        {
            buttons = buttons,
            touches = touches,
            joystickPosition = controller.GetTouchpadAxis(),
            indexTrigger = controller.GetGripAxis(),
            handTrigger = controller.GetTriggerAxis(),
            isActive = true
        });
    }
Exemplo n.º 15
0
 /// <summary>
 /// update touchpad amount and resizing.translate.
 /// </summary>
 void Update()
 {
     if (this != null && this.gameObject != null && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 0 && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 1 && SceneManager.GetActiveScene().buildIndex != 5 && SceneManager.GetActiveScene().buildIndex != 6)
     {
         touchpadamount = vrtkcontrolevents.GetTouchpadAxis().y;
         if ((touchpadamount < -0.1f || touchpadamount > 0.1f) && touchpadDown == true)
         {
             resizing.change(transform.position, scalealterout());
         }
     }
     if (triggerbuttondown)
     {
         resizing.translate(transform.position);
     }
 }
Exemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        float   axisAngle = controllerEvents.GetTouchpadAxisAngle();
        Vector2 axis      = controllerEvents.GetTouchpadAxis();

        Debug.Log("The axis is: " + axis);
        if (controllerEvents.buttonOnePressed)
        {
            superNova.transform.localEulerAngles += Vector3.up * Time.deltaTime * scaleFactor;
        }
        else if (controllerEvents.buttonTwoPressed)
        {
            superNova.transform.localEulerAngles += Vector3.down * Time.deltaTime * scaleFactor;
        }
    }
Exemplo n.º 17
0
    IEnumerator UpdateTouchpadAxis()
    // Coroutine for updating touchpad axis. Runs once per frame.
    {
        while (events.touchpadTouched)
        {
            //Vector2 position = SteamVR_Controller.Input(2).GetAxis();
            Vector2 position = events.GetTouchpadAxis();

            if (getPressedButton(position.x) != pressedButton)
            {
                ButtonPressed(getPressedButton(position.x));
                SwapModels();
            }
            yield return(new WaitForSeconds(0.2f));
        }
    }
Exemplo n.º 18
0
        /*--------------------------------------------------------------------------------------------*/

        private ControlState GetControllerState(VRTK_ControllerEvents control)
        {
            var state = new ControlState
            {
                Controller    = control,
                Tx            = control.transform,
                TouchpadAxis  = control.GetTouchpadAxis(),
                TriggerAxis   = control.GetTriggerAxis(),
                TouchpadTouch = control.touchpadTouched,
                TouchpadPress = control.touchpadPressed,
                GripPress     = control.gripPressed,
                MenuPress     = control.menuPressed
            };

            return(state);
        }
Exemplo n.º 19
0
    void Update()
    {
        if (controllerEvents)
        {
            bool isTouched = controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadTouch) ||
                             controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadPress);

            renderer.enabled = isTouched;

            if (isTouched)
            {
                var currentAxis = controllerEvents.GetTouchpadAxis();
                transform.localPosition = new Vector3(currentAxis.x * scaleX, transform.localPosition.y, currentAxis.y * scaleZ);
            }
        }
    }
Exemplo n.º 20
0
 void Update()
 {
     if (wait <= 0)
     {
         if (controllerEvents.touchpadTouched)
         {
             Vector2 axes = controllerEvents.GetTouchpadAxis();
             if (axes.x > deadZone)
             {
                 cameraRig.transform.Rotate(0, increment, 0);
                 wait = waitTime;
             }
             else if (axes.x < -deadZone)
             {
                 cameraRig.transform.Rotate(0, -increment, 0);
                 wait = waitTime;
             }
         }
     }
     else
     {
         wait -= Time.deltaTime;
     }
 }
    private void Update()
    {
        if (!controllerEvents)
        {
            return;
        }

        bool isTouched = controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadTouch) ||
                         controllerEvents.IsButtonPressed(VRTK_ControllerEvents.ButtonAlias.TouchpadPress);

        var currentAxis = controllerEvents.GetTouchpadAxis();

        if (isTouched && !wasTouched)
        {
            skippedBadInput    = 0;
            lastDir            = 0;
            scrollAmount       = Vector2.zero;
            lastPosition       = currentAxis;
            touchStartPosition = currentAxis;
            touchStartTime     = Time.time;
            StopAllCoroutines();
        }
        else if (!isTouched && wasTouched)
        {
            var touchEndTime = Time.time;
            var touchTime    = touchEndTime - touchStartTime;

            if (touchTime > 0)
            {
                var swipeVector = lastPosition - touchStartPosition;
                var velocity    = swipeVector.magnitude / touchTime;

                if (velocity >= scrollThreshold)
                {
                    var scrollDir = new Vector2(0, Mathf.Sign(swipeVector.y) * invertMultiplier);

                    StartCoroutine(DoScroll(velocity * swipeScale, scrollDir));
                }
            }
        }

        if (isTouched)
        {
            scrollAmount = currentAxis - lastPosition;
            float currentDirection = Mathf.Sign(scrollAmount.y);

            if (Mathf.Abs(scrollAmount.y) >= scrollThreshold)
            {
                if (lastDir != 0 && currentDirection != lastDir && skippedBadInput < numberBadChecks)
                {
                    skippedBadInput++;
                    return;
                }

                skippedBadInput = 0;
                lastPosition    = currentAxis;

                OnScroll(scrollAmount * scrollScale * invertMultiplier);
            }
        }

        wasTouched = isTouched;
    }
Exemplo n.º 22
0
 void Update()
 {
     axes = controller.GetTouchpadAxis();
 }