TriggerHapticPulse() public method

public TriggerHapticPulse ( ushort durationMicroSec = 500, EVRButtonId buttonId = EVRButtonId.k_EButton_SteamVR_Touchpad ) : void
durationMicroSec ushort
buttonId EVRButtonId
return void
 void GrabObject(Collider coll)
 {
     coll.transform.SetParent(gameObject.transform);             // make controller parent
     coll.GetComponent <Rigidbody>().isKinematic = true;         // turn off physics
     device.TriggerHapticPulse(2000);                            // vibrate controller
     Debug.Log("Grabbing object!");
 }
Beispiel #2
0
 // Token: 0x06002170 RID: 8560 RVA: 0x000A4FC4 File Offset: 0x000A31C4
 private void Update()
 {
     if (this.renderModel != null && this.renderModel.gameObject.activeInHierarchy && this.flashingRenderers.Count > 0)
     {
         Color color = this.controllerMaterial.GetColor(this.colorID);
         float num   = (Time.realtimeSinceStartup - this.startTime) * 3.14159274f * 2f;
         num = Mathf.Cos(num);
         num = Util.RemapNumberClamped(num, -1f, 1f, 0f, 1f);
         if (Time.realtimeSinceStartup - this.startTime - this.tickCount > 1f)
         {
             this.tickCount += 1f;
             SteamVR_Controller.Device device = SteamVR_Controller.Input((int)this.renderModel.index);
             if (device != null)
             {
                 device.TriggerHapticPulse(500, EVRButtonId.k_EButton_Axis0);
             }
         }
         for (int i = 0; i < this.flashingRenderers.Count; i++)
         {
             this.flashingRenderers[i].material.SetColor(this.colorID, Color.Lerp(color, this.flashColor, num));
         }
         if (this.initialized)
         {
             foreach (KeyValuePair <EVRButtonId, ControllerButtonHints.ButtonHintInfo> keyValuePair in this.buttonHintInfos)
             {
                 if (keyValuePair.Value.textHintActive)
                 {
                     this.UpdateTextHint(keyValuePair.Value);
                 }
             }
         }
     }
 }
 void GrabObject(Collider coli)
 {
     coli.transform.SetParent(gameObject.transform);
     coli.GetComponent <Rigidbody>().isKinematic = true;
     device.TriggerHapticPulse(2000);
     //Debug.Log("you're pulling the trigger on an object");
 }
Beispiel #4
0
 void GrabObject(Collider coli)
 {
     coli.transform.SetParent(gameObject.transform);
     coli.GetComponent <Rigidbody> ().isKinematic = true;
     device.TriggerHapticPulse(2000);
     Debug.Log("You are touching down the trigger on an object.");
 }
Beispiel #5
0
 void GrabObject(Collider coli)
 {
     coli.transform.SetParent(gameObject.transform);
     coli.GetComponent <Rigidbody>().isKinematic = true; // Stop physics from acting on the object
     device.TriggerHapticPulse(2000);
     Debug.Log("You have grabbed the " + coli.gameObject.name);
 }
 IEnumerator DoPulse(SteamVR_Controller.Device controller)
 {
     for (float i = 0; i < 0.1f; i += Time.deltaTime)
     {
         controller.TriggerHapticPulse((ushort)(2000));
         yield return(null);
     }
 }
Beispiel #7
0
 IEnumerator Vibrate()
 {
     for (float time = 0; time < 0.1f; time += Time.deltaTime)
     {
         device.TriggerHapticPulse(4000);
         yield return(null);
     }
 }
Beispiel #8
0
 void rumbleController()
 {
     if (shake)
     {
         device.TriggerHapticPulse(5000, Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad);
         device2.TriggerHapticPulse(5000, Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad);
     }
 }
 void Update()
 {
     device = SteamVR_Controller.Input((int)trackedObject.index);
     if (hapticFlag)
     {
         device.TriggerHapticPulse(1500);
     }
 }
Beispiel #10
0
 IEnumerator HapticSinglePulse(float length)
 {
     for (float i = 0; i < length; i += Time.deltaTime)
     {
         device.TriggerHapticPulse();
         yield return(null);
     }
 }
 IEnumerator PulseHaptics(SteamVR_Controller.Device controller)
 {
     for (int i = 0; i < HapticPulseCount; i++)
     {
         controller.TriggerHapticPulse();
         yield return(new WaitForSecondsRealtime(0.001f));
     }
 }
Beispiel #12
0
        protected virtual void FixedUpdate()
        {
            LastPositions[EstimationSampleIndex] = this.transform.position;
            LastRotations[EstimationSampleIndex] = this.transform.rotation;
            LastDeltas[EstimationSampleIndex]    = Time.fixedDeltaTime;
            EstimationSampleIndex++;

            if (EstimationSampleIndex >= LastPositions.Length)
            {
                EstimationSampleIndex = 0;
            }

            if (Controller != null && IsInteracting == false && IsHovering == true)
            {
                Controller.TriggerHapticPulse(100);
            }
        }
Beispiel #13
0
    void TriggerPressed(object sender, ClickedEventArgs e)
    {
        updateMax();

        device = SteamVR_Controller.Input((int)trackedObject.index);
        device.TriggerHapticPulse(900);
        Debug.Log("left trigger pressed");
    }
 public IEnumerator LongVibration(float length, float strength)
 {
     for (float i = 0; i < length; i += Time.deltaTime)
     {
         device.TriggerHapticPulse((ushort)Mathf.Lerp(0, 3999, strength));
         yield return(null);
     }
 }
 void DoPulse(int amount)
 {
     SteamVR_Controller.Device device = SteamVR_Controller.Input((int)_trackedObject.index);
     if (device != null)
     {
         device.TriggerHapticPulse((ushort)amount);
     }
 }
Beispiel #16
0
 void GrabbingObject(Collider GrabbingOBJ)
 {
     if (GrabbingOBJ.CompareTag("Throwable") && BallReset.ballThrowable)
     {
         Debug.Log(BallReset.ballThrowable);
         GrabbingOBJ.transform.SetParent(gameObject.transform);
         GrabbingOBJ.GetComponent <Rigidbody>().isKinematic = true;
         ControllerDevice.TriggerHapticPulse(2000);
         BallReset.isOnHand = true;
     }
     if (GrabbingOBJ.CompareTag("Structure"))
     {
         GrabbingOBJ.transform.SetParent(gameObject.transform);
         GrabbingOBJ.GetComponent <Rigidbody>().isKinematic = true;
         ControllerDevice.TriggerHapticPulse(2000);
     }
 }
Beispiel #17
0
 private IEnumerator vibrationThread(float length, float strength, SteamVR_Controller.Device device)
 {
     for (float i = 0; i < length; i += Time.deltaTime)
     {
         device.TriggerHapticPulse((ushort)Mathf.Lerp(0, 3999, strength));
         yield return(null); //every single frame for the duration of "length" you will vibrate at "strength" amount
     }
 }
Beispiel #18
0
 public void CollidedWith(GameObject collided)
 {
     device.TriggerHapticPulse(500);
     if (handle == null)
     {
         handle = collided;
     }
 }
Beispiel #19
0
 public IEnumerator vibrateRight(float length)
 {
     for (float i = 0; i < length; i += Time.deltaTime)
     {
         device.TriggerHapticPulse((ushort)2000f);
         yield return(null);
     }
 }
Beispiel #20
0
 IEnumerator StartHapticVibrationCoroutine(SteamVR_Controller.Device device, float length, float strength)
 {
     for (float i = 0; i < length; i += Time.deltaTime)
     {
         device.TriggerHapticPulse((ushort)Mathf.Lerp(0, 3999, strength));
         yield return(null);
     }
 }
Beispiel #21
0
 void GrabObject(Collider coli)
 {
     coli.transform.SetParent(gameObject.transform);
     coli.GetComponent <Rigidbody>().isKinematic = true;
     device.TriggerHapticPulse(2000);
     gameObject.GetComponent <AudioSource>().Play();
     Debug.Log("touching down the trigger");
 }
Beispiel #22
0
 void OnTrigger(object sender, ClickedEventArgs e)
 {
     if (pointerOver && pointerOver.GetComponent <TextMesh>() && tController.triggerPressed)
     {
         SteamVR_Controller.Device device = SteamVR_Controller.Input((int)GetComponent <SteamVR_TrackedObject>().index);
         device.TriggerHapticPulse();
         touchpad = pointerOver.GetComponent <TextMesh>().text == "Touchpad" ? true : false;
     }
 }
Beispiel #23
0
 IEnumerator Shake(float time)
 {
     Invoke("StopShake", time);
     while (!isNotShake)
     {
         device.TriggerHapticPulse(500);
         yield return(new WaitForEndOfFrame());
     }
 }
    /*
     *
     * private void OnCollisionEnter(Collision other)
     * {
     *  print("Shield collision with something");
     *
     *  if (other.gameObject.tag == "EnemyBullet")
     *  {
     *
     *      print("Shield found bullet");
     *      float otherDamage = other.gameObject.GetComponent<EnemyBullet>().damage;
     *
     *      for (int i = 0; i < meshesToChange.Length; i++)
     *      {
     *          meshesToChange[i].GetComponent<Renderer>().material.SetColor("_MainColor", flashColor);
     *      }
     *
     *      healthText.material.SetColor("_GlowColor", flashColor);
     *
     *      shieldHealth -= otherDamage;
     *
     *      //scanTileCurrent = 0;
     *      flickerSpeedCurrent = flickerSpeedMax;
     *
     *      StartCoroutine(ShieldVibration(1, 2000));
     *
     *      // A chance to absorb an incoming bullet
     *      //float shieldAbsorption = Random.Range(0f, 1f);
     *      //if (shieldAbsorption > shieldBulletAbsorbtionAmount)
     *      {
     *          playerController.playerBullets += shieldBulletAbsorbtionAmount;
     *          Instantiate(bulletGainedObj, other.gameObject.transform.position, other.gameObject.transform.rotation);
     *      }
     *
     *      //print("Hit");
     *
     *      Destroy(other.gameObject);
     *  }
     * }
     */

    /*private void OnTriggerEnter(Collider other)
     * {
     *  if (other.gameObject.tag == "EnemyBullet")
     *  {
     *      float otherDamage = other.gameObject.GetComponent<EnemyBullet>().damage;
     *      shieldHealth -= otherDamage;
     *
     *      scanTileCurrent = 0;
     *      flickerSpeedCurrent = flickerSpeedMax;
     *
     *      StartCoroutine(ShieldVibration(1, 2000));
     *
     *      // A chance to absorb an incoming bullet
     *      //float shieldAbsorption = Random.Range(0f, 1f);
     *      //if (shieldAbsorption > shieldBulletAbsorbtionAmount)
     *      {
     *          playerController.playerBullets += shieldBulletAbsorbtionAmount;
     *      }
     *
     *      //print("Hit");
     *
     *      //Destroy(other.gameObject);
     *  }
     * }*/

    IEnumerator ShieldVibration(float length, ushort strength)
    {
        for (float i = 0; i < length; i += Time.deltaTime)
        {
            device.TriggerHapticPulse(strength);
            strength = (ushort)Mathf.Lerp(strength, 0, Time.deltaTime * 5);
            yield return(null); //every single frame for the duration of "length" you will vibrate at "strength" amount
        }
    }
Beispiel #25
0
 IEnumerator LongVibration(SteamVR_Controller.Device device, float length, ushort strength)
 {
     for (float i = 0; i < length; i += Time.deltaTime)
     {
         //  Vibrate for length at given strength
         device.TriggerHapticPulse(strength);
         yield return(null);
     }
 }
 // Update is called once per frame
 void Update()
 {
     trigger = SteamVR_Controller.Input((int)trackedObject.index);
     if (trigger.GetPressDown(triggerButton))
     {
         Debug.Log("triggered");
         trigger.TriggerHapticPulse(900);
     }
 }
 private void Update()
 {
     if (_currentDuration < _duration)
     {
         _currentDuration += Time.deltaTime;
         device            = SteamVR_Controller.Input((int)sto.index);
         device.TriggerHapticPulse((ushort)currentStrength());
     }
 }
 // Update is called once per frame
 void Update()
 {
     System.TimeSpan duration = System.DateTime.Now - startVibrateTime;
     if (duration.TotalMilliseconds < vibrateMilliSecond)
     {
         device = SteamVR_Controller.Input((int)controller.index);
         device.TriggerHapticPulse();
     }
 }
    void GrabObject(Collider coli)
    {
        //Renderer renderMaterial = coli.GetComponent<Renderer> ();
        coli.transform.SetParent(gameObject.transform);
        coli.GetComponent <Rigidbody> ().isKinematic = true;
        myDevice.TriggerHapticPulse(5000);          // pulse may be too short to feel it

        /*	if(checkPlayArea.isPlayArea == true){	//check if ball inside play area
         *              Debug.Log ("Grab the ball and will score, ball inside playarea");
         *      }
         *
         *      if(checkPlayArea.isPlayArea == false){ //check if ball outside play area
         *              //renderMaterial.material.color = Color.blue;
         *              //coli.gameObject.layer = 11;
         *              Debug.Log ("Grab the ball and will NOT score, ball outside playarea");
         *      }
         */
    }
 public override void TriggerHapticPulse(ushort durationMicroSec = 500, NVRButtons button = NVRButtons.Touchpad)
 {
     if (Controller != null)
     {
         if (durationMicroSec < 3000)
         {
             Controller.TriggerHapticPulse(durationMicroSec, ButtonMapping[button]);
         }
     }
 }
    private void Update()
    {
        controllerIndex = (uint)trackedController.index;
        device = SteamVR_Controller.Input((int)controllerIndex);

        if (hapticPulseCountdown > 0)
        {
            device.TriggerHapticPulse(hapticPulseStrength);
            hapticPulseCountdown -= 1;
        }
    }
Beispiel #32
0
        IEnumerator DoStartCoroutine()
        {
            var i = -1;
            if ((int)trackedObj.index > i++)
            {
                device = SteamVR_Controller.Input((int)trackedObj.index);
                strength.Value = Mathf.Clamp01(strength.Value);
                float startTime = FsmTime.RealtimeSinceStartup;

                while (FsmTime.RealtimeSinceStartup - startTime <= duration.Value)
                {
                    int valveStrength = Mathf.RoundToInt(Mathf.Lerp(0, 3999, strength.Value));

                    device.TriggerHapticPulse((ushort)valveStrength);
                    yield return null;
                }

                var curTime = FsmTime.RealtimeSinceStartup - duration.Value;
                if (curTime > duration.Value)
                {
                    Fsm.Event(sendEvent);
                }
            }
        }
    // Update is called once per frame
    void Update()
    {
        // return if I am not a hunter player
        if (!isActive || !isLocalPlayer)
            return;

        // Flags for determining controller state per frame
        bool leftActive = true;
        bool leftTriggerPulled = false;
        bool rightTriggerPulled = false;
        bool leftGripPressed = false;
        bool rightGripPressed = false;

        // Setup Vive Controller
        try {
            rightController = SteamVR_Controller.Input((int)rightTrackedObject.index);
            rightTriggerPulled = rightController.GetPressDown(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
            rightGripPressed = rightController.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip);
        } catch (System.Exception) {
            Debug.Log ("No controllers Connected");
        }

        bool triggersPulled = (leftTriggerPulled || rightTriggerPulled);
        bool gripsPressed = (leftGripPressed || rightGripPressed);
        // waiting for some time at the beginning of the game
        // such that the hiders have enough time to hide
        if (waiting) {
            int secondsElapsed = (int)Time.timeSinceLevelLoad;
            if (secondsElapsed < 15) {
                UIText.text = "Wait for " + (15 - secondsElapsed) + " second(s)";
                return;
            }
            else {
                waiting = false;
                GetComponent<myViveController>().enabled = true;
            }
        }

        // return if game is over
        if (timer.GameOver()) {
            GetComponent<myPlayerController>().enabled = false;
            UIText.text = "Game Over!";
            GetComponent<PointCounter> ().stopCounting ();
            return;
        }

        // time counter: can only shoot when a certain amount of time (FireRate) has passed
        timeCounter += Time.deltaTime;

        // Raycasting - used for shooting and opening doors
        if (isServer) {
            //Ray leftControllerRay = new Ray (leftTrackedObject.transform.position, leftTrackedObject.transform.forward);
            Ray rightControllerRay = new Ray (rightTrackedObject.transform.position, rightTrackedObject.transform.forward);
            RaycastHit objectHit;
            GameObject obj = null;
            if (Physics.Raycast(rightControllerRay, out objectHit, ShootDistance)) {
                obj = objectHit.transform.gameObject;
                // if aiming at a player
                if (obj.tag.Equals("Player")) {

                }
                else if (obj.tag.Equals("Door") && objectHit.distance < InteractDistance) {
                    UIText.text = "Press the trigger button to open/close the door";

                    // VIVE REIMPLEMENT
                    if (triggersPulled) {
                        GetComponent<AudioSource>().PlayOneShot(doorSound, 2f);
                        doorController.CmdMoveDoor(obj);
                    }
                }
                else {
                    UIText.text = "";
                }
            }
            else {
                UIText.text = "";
            }

            // VIVE REIMPLEMENT
            if (triggersPulled && timeCounter > FireRate) {
                // reset time counter
                timeCounter = 0.0f;

                // play the gun sound effect
                GetComponent<AudioSource>().Play();
                // Haptic feedback!
                rightController.TriggerHapticPulse (1200);

                if (obj != null && obj.tag.Equals("Player")) {
                    GameObject playerHit = obj;
                    playerHit.GetComponent<PropController>().TakeDamage(Damage);
                    this.gameObject.GetComponent<PointCounter> ().addKillPoints ();

                    Debug.Log("Hit: " + playerHit);
                }
            }
        } else {
            Ray camRay = myCamera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2));
            RaycastHit objectHit;
            GameObject obj = null;
            if (Physics.Raycast(camRay, out objectHit, ShootDistance)) {
                obj = objectHit.transform.gameObject;
                // if aiming at a player
                if (obj.tag.Equals("Player")) {

                }
                else if (obj.tag.Equals("Door") && objectHit.distance < InteractDistance) {
                    UIText.text = "Press the Grip button to open/close the door";

                    // VIVE REIMPLEMENT
                    if (triggersPulled) {
                        GetComponent<AudioSource>().PlayOneShot(doorSound, 2f);
                        doorController.CmdMoveDoor(obj);
                    }
                }
                else {
                    UIText.text = "";
                }
            }
            else {
                UIText.text = "";
            }

            // VIVE REIMPLEMENT
            if (triggersPulled && timeCounter > FireRate) {
                // reset time counter
                timeCounter = 0.0f;

                rightController.TriggerHapticPulse(700);
                // play the gun sound effect
                GetComponent<AudioSource>().Play();

                if (obj != null && obj.tag.Equals("Player")) {
                    GameObject playerHit = obj;
                    playerHit.GetComponent<PropController>().TakeDamage(Damage);
                    Debug.Log("Hit: " + playerHit);
                }
            }
        }
    }