Example #1
0
    private IEnumerator SwitchWeapon(HackerHand hand)
    {
        selectedWeaponIndex = (selectedWeaponIndex + 1) % selectionPositions.Length;
        var touchPos    = selectionPositions[selectedWeaponIndex];
        var touchPosVec = new Vector2(touchPos[0], touchPos[1]) * 0.8f;

        player.OpenAbilitySelectionWheel(hand);
        yield return(new WaitForFixedUpdate());

        player.SetAbilitySelectionPosition(hand, touchPosVec);
        yield return(new WaitForSeconds(0.2f));

        player.ConfirmAbilitySelection(hand, touchPosVec);
        yield return(new WaitForSeconds(0.1f));

        player.CloseAbilitySelectionWheel(hand);
    }
    void Update()
    {
        SteamVR_Controller.Device controller = GetController();
        if (trackedController.padTouched)
        {
            Vector2 touchPosition = controller.GetAxis();
            player.SetAbilitySelectionPosition(hand, touchPosition);
        }

        if (hapticRemainingDuration > 0)
        {
            hapticRemainingDuration -= Time.unscaledDeltaTime;

            // trigger the pulse for each frame for the duration
            ushort nativeStrength = (ushort)(Mathf.Clamp01(hapticStrength) * 3999);
            controller.TriggerHapticPulse(nativeStrength);
        }
    }