示例#1
0
        void UpdateAnimatorKnuckles()
        {
            SteamVR_Input_Sources inputSource = (controllerHand.IsLeft) ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand;

            if (!assistActionset.IsActive())
            {
                assistActionset.Activate(inputSource);
            }

            animator.SetBool(isGrabbedHash, grabGrip.GetState(inputSource));

            faceButtonTouch = (aButtonTouch.GetState(inputSource) || bButtonTouch.GetState(inputSource) ||
                               trackpadTouch.GetState(inputSource));

            isTriggerTouch = triggerTouch.GetState(inputSource);
            isPinching     = faceButtonTouch;
            if (faceButtonTouch)
            {
                pinchThumbHoriz += (trackpadTouch.GetState(inputSource) ? -1 : 1) * Time.deltaTime * 6;
                pinchThumbHoriz  = Mathf.Clamp01(pinchThumbHoriz);
            }

            animator.SetBool(isPinchingHash, isPinching);
            animator.SetFloat(pinchAmtHash, skeletonBehavior.fingerCurls[1]);
            animator.SetFloat(pinchThumbHorizHash, pinchThumbHoriz);

            pinchTweenTime += (isPinching) ? Time.deltaTime : -Time.deltaTime;
            pinchTweenTime  = Mathf.Clamp(pinchTweenTime, 0, pinchTweenDuration);
            pinchTValue     = Mathf.InverseLerp(0, pinchTweenDuration, pinchTweenTime);
            if (skeletonBehavior)
            {
                skeletonBehavior.indexSkeletonBlend = 1 - pinchTValue;
                skeletonBehavior.thumbSkeletonBlend = 1 - pinchTValue;
            }
        }
示例#2
0
 private void updateLasersActionSetState()
 {
     if (!mainActionSet.IsActive())
     {
         laserActionSet.Deactivate();
         return;
     }
     if (laserActionSet.IsActive() && VRPlayer.activePointer == null)
     {
         laserActionSet.Deactivate();
     }
     else if (!laserActionSet.IsActive() && VRPlayer.activePointer != null)
     {
         laserActionSet.Activate(SteamVR_Input_Sources.Any, 1 /* Higher priority than main action set */);
     }
 }
示例#3
0
    private void Update()
    {
        if (interactable.attachedToHand == null || crushable == false)
        {
            return;
        }

        if (setToActivate.IsActive() == false)
        {
            setToActivate.ActivatePrimary();
        }

        SteamVR_Input_Sources hand = interactable.attachedToHand.handType;

        float squeeze = actionSqueeze.GetAxis(hand);

        foreach (Renderer rend in renderers)
        {
            rend.material.SetColor("_EmissionColor", (glowColor * Mathf.Pow(squeeze * 2.5f, 2)));
        }

        bool crush = actionCrush.GetStateDown(hand);

        if (crush)
        {
            Instantiate(BrokenPrefab, transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
        else
        {
            float stress = Mathf.Pow(squeeze, 2);

            if (squeeze > 0.3f)
            {
                interactable.attachedToHand.TriggerHapticPulse((ushort)Mathf.Lerp(200, 1000, squeeze * 2));
            }

            Vector3 shake = new Vector3(Random.Range(-shakingAmount, shakingAmount), Random.Range(-shakingAmount, shakingAmount), Random.Range(-shakingAmount, shakingAmount));
            shake *= stress;
            rigidbody.AddForce(shake * 20000, ForceMode.Impulse);
        }
    }
示例#4
0
    public void Update()
    {
        touchpadDown = SteamVR_Input._default.inActions.Teleport.GetStateDown(hand.handType);
        touchpadHeld = SteamVR_Input._default.inActions.Teleport.GetState(hand.handType);
        touchpadUp   = SteamVR_Input._default.inActions.Teleport.GetStateUp(hand.handType);

        // triggerUp is flaged at triggerValue = 0.2,
        // triggerDown is flagged at triggerValue = .25
        // so the triggerHeld uses a deadzone to adjust, but I suggest using Held OR Up/Down OR Value to avoid bugs
        triggerDown  = SteamVR_Input._default.inActions.InteractUI.GetStateDown(hand.handType);
        triggerHeld  = (SteamVR_Input._default.inActions.Squeeze.GetAxis(hand.handType) > triggerDeadzone);
        triggerUp    = SteamVR_Input._default.inActions.InteractUI.GetStateUp(hand.handType);
        triggerValue = SteamVR_Input._default.inActions.Squeeze.GetAxis(hand.handType);

        gripDown = SteamVR_Input._default.inActions.GrabGrip.GetStateDown(hand.handType);
        gripHeld = SteamVR_Input._default.inActions.GrabGrip.GetState(hand.handType);
        gripUp   = SteamVR_Input._default.inActions.GrabGrip.GetStateUp(hand.handType);

        // Turns platformer and trackpad action sets back on if something in the scene turns them off
        if (!platformer.IsActive())
        {
            platformer.ActivateSecondary();
        }
        trackpad = trackpadAction.GetAxis(hand.handType);
        if (!buggy.IsActive())
        {
            buggy.ActivateSecondary();
        }
        menuDown = menuDownAction.GetStateDown(hand.handType);

        /* This doesn't work so it's disabled ATM
         * if (lineCast)
         * {
         *  LineCast();
         * }*/

        if (debug)
        {
            DebugActions();
        }
    }
    private void ActionActivityController()
    {
        if (dimExplorer.dimensionExpLorerLoaded)
        {
            dimExplorerActions.Activate();
            vizNavActions.Deactivate();
        }
        else if (vizController.vizFullyLoaded)
        {
            vizNavActions.Activate();
            dimExplorerActions.Deactivate();
        }


        if (dimExplorer.dimExKeyboard.keyboardLoaded)
        {
            dimExplorerActions.Activate();
            vizNavActions.Deactivate();
        }


        if (dimExplorer.dimExKeyboard.keyboardMoving)
        {
            dimExplorerActions.Deactivate();
            vizNavActions.Deactivate();
        }


        if (timeline.timelineLoaded)
        {
            timelineActions.Activate();
        }
        else
        {
            timelineActions.Deactivate();
        }

        menuInteractionActions.Activate();


        // debugging
        if (false)
        {
            //Debug.Log("dimensionExpLorerLoaded: " + dimExplorer.dimensionExpLorerLoaded + " | vizFullyLoaded: " + vizController.vizFullyLoaded + " | keyboardLoaded: " + dimExplorer.dimExKeyboard.keyboardLoaded + " | keyboardMoving: " + dimExplorer.dimExKeyboard.keyboardMoving);

            string activeSetDebug = "Active Sets:";
            if (defaultActions.IsActive())
            {
                activeSetDebug += " | default";
            }
            if (vizNavActions.IsActive())
            {
                activeSetDebug += " | viz";
            }
            if (dimExplorerActions.IsActive())
            {
                activeSetDebug += " | dimEx";
            }
            if (menuInteractionActions.IsActive())
            {
                activeSetDebug += " | menu";
            }
            if (timelineActions.IsActive())
            {
                activeSetDebug += " | timeline";
            }
            Debug.Log(activeSetDebug);
        }
    }
 private void Start()
 {
     Debug.Log("Action set enabled = " + actionSet.IsActive(SteamVR_Input_Sources.Any));
 }
示例#7
0
        public void Update()
        {
            updateMainActionSetState();
            updateLasersActionSetState();
            if (mainActionSet.IsActive())
            {
                checkRecenterPose(Time.deltaTime);
            }

            checkQuickItems <QuickSwitch>(StaticObjects.quickSwitch, SteamVR_Actions.valheim_QuickSwitch, true);
            checkQuickItems <QuickActions>(StaticObjects.quickActions, SteamVR_Actions.valheim_QuickActions, false);
        }