void FocusSeal(object sender, ControllerInteractionEventArgs e)
    {
        sealFocused = false;

        if (controllerEvents.GetTriggerAxis() >= 0.5f - focusRange &&
            (magicScript.FocusActive || controllerEvents.GetTriggerAxis() <= 0.5f + focusRange))
        {
            sealFocused = true;
        }
    }
Exemple #2
0
    void Update()
    {
        //Debug.Log ("Right Trigger Axis: " + rightController.GetTriggerAxis ());

        engine.Accelerate(rightController.GetTriggerAxis());
        engine.Accelerate(-1 * leftController.GetTriggerAxis());
    }
    void Update()
    {
        //HandAverage is the average point between both hands that controls the board when both grip buttons are pressed
        HandAverage.position = Vector3.Lerp(MainHand.position, OffHand.position, .5f);
        HandAverage.rotation = Quaternion.Lerp(MainHand.rotation, OffHand.rotation, .5f);
        HandAverage.LookAt(MainHand.position, HandAverage.up);

        bool leftHand  = (LeftControllerEvents.gripPressed) ? true : false;
        bool rightHand = (RightControllerEvents.gripPressed) ? true : false;

        //bool leftHand  = OVRInput.Get(OVRInput.Button.PrimaryHandTrigger, OVRInput.Controller.LTouch);
        //bool rightHand = OVRInput.Get(OVRInput.Button.PrimaryHandTrigger, OVRInput.Controller.RTouch);

        SetMovementIndicators(leftHand, rightHand);

        _dampener.Target = GetDampenerTarget(leftHand, rightHand);

        ScaleMode = leftHand && rightHand;

        UpdateDisplayMode();

        UpdateScaleMode();
        UpdateTimeline();

        HighlighterScript.ShowHighlight = (RightControllerEvents.GetTriggerAxis() == 1) ? true : false;
        //HighlighterScript.ShowHighlight = OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.RTouch);
    }
    private void Update()
    {
        if (m_headset != null && m_playArea != null)
        {
            float inputValue = m_controllerEvents.GetTriggerAxis();

            if (inputValue > inputDeadZone)
            {
                Vector3 dir = m_headset.forward;

                if (rollTurnMultiplier != 0)
                {
                    var euler = m_headset.eulerAngles;
                    euler.z = 0;

                    var worldUp = Vector3.up;
                    worldUp = Quaternion.Euler(euler) * worldUp;

                    var headUp = m_headset.up;
                    var tilt   = Vector3.ProjectOnPlane(headUp, worldUp);

                    dir += tilt * rollTurnMultiplier;
                }

                m_playArea.position += (Mathf.Pow(inputValue + 1, speedPow) - 1) * speedMultiplier * Time.deltaTime * dir;
            }
        }
    }
Exemple #5
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;
            }
        }
    }
    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);
            }
        }
    }
 void MoveWeaponTrigger()
 {
     if (controllerEvents != null)
     {
         var pressure = (maxTriggerRotation * controllerEvents.GetTriggerAxis()) - minTriggerRotation;
         trigger.localEulerAngles = new Vector3(pressure, 0f, 0f);
     }
     else
     {
         trigger.localEulerAngles = new Vector3(minTriggerRotation, 0f, 0f);
     }
 }
Exemple #8
0
 protected override void Update()
 {
     base.Update();
     if (controllerEvents)
     {
         var pressure = (maxTriggerRotation * controllerEvents.GetTriggerAxis()) - minTriggerRotation;
         trigger.transform.localEulerAngles = new Vector3(0f, pressure, 0f);
     }
     else
     {
         trigger.transform.localEulerAngles = new Vector3(0f, minTriggerRotation, 0f);
     }
 }
Exemple #9
0
 protected override void Update()
 {
     base.Update();
     if (controllerEvents)
     {
         var power = controllerEvents.GetTriggerAxis();
         Spray(power);
         controllerActions.TriggerHapticPulse(Convert.ToUInt16(1000f * power), 0.1f, 0.01f);
     }
     else
     {
         Spray(0f);
     }
 }
    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);
    }
Exemple #11
0
 protected override void Update()
 {
     base.Update();
     if (controllerEvents)
     {
         float power = controllerEvents.GetTriggerAxis();
         Spray(power);
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject), power * 0.25f, 0.1f, 0.01f);
     }
     else
     {
         Spray(0f);
     }
 }
 protected override void Update()
 {
     base.Update();
     if (controllerEvents)
     {
         float power = controllerEvents.GetTriggerAxis();
         Spray(power);
         VRTK_SharedMethods.TriggerHapticPulse(VRTK_DeviceFinder.GetControllerIndex(controllerEvents.gameObject), power * 0.25f, 0.1f, 0.01f);
     }
     else
     {
         Spray(0f);
     }
 }
Exemple #13
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
        });
    }
 private void Update()
 {
     if (events != null)
     {
         var triggerAmount = events.GetTriggerAxis();
         if (trigger != null && triggerAmount != trigger.Amount)
         {
             trigger.Amount = triggerAmount;
             if (animator != null)
             {
                 animator.Amount = triggerAmount;
             }
         }
     }
 }
Exemple #15
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);
        }
Exemple #16
0
 // Update is called once per frame
 protected override void Update()
 {
     base.Update();
     if (controllerEvents)
     {
         float power = controllerEvents.GetTriggerAxis();
         if (Time.time > timer)
         {
             TurnOnMachine();
             timer = Time.time + spawnDelay;
         }
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject), power * 0.25f, 0.1f, 0.01f);
     }
     else
     {
     }
 }
Exemple #17
0
    void CheckForController(Collider other)
    {
        VRTK_ControllerEvents events = other.GetComponentInParent <VRTK_ControllerEvents>();

        if (events == null)
        {
            return;
        }

        if (events.GetTriggerAxis() >= events.triggerClickThreshold)
        {
            if (isLit && isExtinguishable)
            {
                IsLit = false;
            }
        }
    }
Exemple #18
0
    protected virtual void InputHandle()
    {
        if (controllerEvents)
        {
            trigger.localPosition = new Vector3(triggerRestPos.x + (0.07f * controllerEvents.GetTriggerAxis()), triggerRestPos.y, triggerRestPos.z);

            if (controllerEvents.touchpadPressed)
            {
                float angle = controllerEvents.GetTouchpadAxisAngle();
                if (angle < 45 || angle > 315)
                {
                    SlideStopped = false;
                }
                else if (angle < 225 && angle > 135)
                {
                    if (magRelease)
                    {
                        UnLoadMagazine();
                    }
                }
            }


            if (controllerEvents.triggerClicked && (!fired || fullAuto))
            {
                FireBullet();
                fired = true;
            }

            if (fired && !controllerEvents.triggerClicked)
            {
                fired = false;
            }
        }
        else
        {
            trigger.localPosition = triggerRestPos;
        }
    }
Exemple #19
0
    public void OnEvent(StartInteractionConceptEvent e)
    {
        if (e.newConcept == InteractionConcept.ScaleRotate)
        {
            VRTK_ControllerEvents leftController = VRTK.VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();

            showScaleRotateMenu = new ControllerInteractionEventHandler(UpdateScaleRotateMenu);
            leftController.TriggerAxisChanged += showScaleRotateMenu;

            startIdle = new ControllerInteractionEventHandler(StartIdle);
            leftController.TriggerTouchEnd += startIdle;

            // set inital animation progress and show menu
            scaleRotateMenu.SetActive(true);
            scaleRotateMenu.gameObject.GetComponent <ScaleAnimator>().SetAnimationProgress(leftController.GetTriggerAxis());

            Hint.Display("HowToScaleTranslate1Hint");
            Hint.Display("HowToScaleTranslate2Hint");
        }
    }