Example #1
0
    public void AttachBowToArrow()
    {
        currentArrow.transform.parent   = stringAttachPoint.transform;
        currentArrow.transform.position = arrowStartPoint.transform.position;
        currentArrow.transform.rotation = arrowStartPoint.transform.rotation;

        VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 1f, .1f, .005f);
        isAttached = true;
        //currentArrow.GetComponent<Rigidbody>().detectCollisions = false;
    }
Example #2
0
    IEnumerator KeepVibrating()
    {
        while (isVibrating)
        {
            VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(LeftController), strength, duration, pulseInterval);
            VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(RightController), strength, duration, pulseInterval);

            yield return(new WaitForSeconds(duration));
        }
    }
Example #3
0
 // Update is called once per frame
 void Update()
 {
     if (!_switch)
     {
         return;
     }
     if (active)
     {
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(gameObject), Strength);
     }
 }
Example #4
0
 // Token: 0x06001ECE RID: 7886 RVA: 0x0009C674 File Offset: 0x0009A874
 private void PullString()
 {
     this.currentPull = Mathf.Clamp((Vector3.Distance(this.holdControl.transform.position, this.stringControl.transform.position) - this.pullOffset) * this.pullMultiplier, 0f, this.maxPullDistance);
     this.bowAnimation.SetFrame(this.currentPull);
     if (!this.currentPull.ToString("F2").Equals(this.previousPull.ToString("F2")))
     {
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(this.holdControl.gameObject), this.bowVibration);
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(this.stringControl.gameObject), this.stringVibration);
     }
     this.previousPull = this.currentPull;
 }
Example #5
0
 // Token: 0x06001E0C RID: 7692 RVA: 0x000989A4 File Offset: 0x00096BA4
 private void OnCollisionEnter(Collision collision)
 {
     if (VRTK_ControllerReference.IsValid(this.controllerReference) && this.IsGrabbed(null))
     {
         this.collisionForce = VRTK_DeviceFinder.GetControllerVelocity(this.controllerReference).magnitude *this.impactMagnifier;
         float strength = this.collisionForce / this.maxCollisionForce;
         VRTK_ControllerHaptics.TriggerHapticPulse(this.controllerReference, strength, 0.5f, 0.01f);
         return;
     }
     this.collisionForce = collision.relativeVelocity.magnitude * this.impactMagnifier;
 }
Example #6
0
        private void FireBullet()
        {
            GameObject bulletClone = Instantiate(bullet, bullet.transform.position, bullet.transform.rotation) as GameObject;

            bulletClone.SetActive(true);
            Rigidbody rb = bulletClone.GetComponent <Rigidbody>();

            rb.AddForce(-bullet.transform.forward * bulletSpeed);
            VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 10, 0.5f, 0.05f);
            Destroy(bulletClone, bulletLife);
        }
Example #7
0
 protected virtual void FireProjectile(int damage)
 {
     if (projectile != null && projectileSpawnPoint != null && countdown)
     {
         proj = projectile.GetComponent<Particles>();
         proj.dice = damage;
         Instantiate(projectile, projectileSpawnPoint.position, projectileSpawnPoint.rotation);
         VRTK_ControllerHaptics.TriggerHapticPulse(cref, 65*damage, 0.1f, 0.01f);
         charge -= (float)(damage * 0.5);
     }
 }
Example #8
0
    private void OnTriggerEnter(Collider other)
    {
        if (!(other.gameObject.layer == 12 || other.gameObject.layer == 13))
        {
            return;
        }

        controllerReference = GetComponent <WeaponHaptics>().controllerReference;
        //velocity = VRTK_DeviceFinder.GetControllerVelocity(controllerReference);

        velocity = rb.velocity;

        if (velocity.magnitude >= minimumSpeedToProduceSound)
        {
            // play randomized sound effect
            AkSoundEngine.PostEvent(akEventCollision, this.gameObject);
            lastTimeSoundWasPlayed = Time.time;
        }

        int damage = baseDamage;

        if ((other.gameObject.layer == 12 || other.gameObject.layer == 13))
        {
            StateController state_controller = other.gameObject.GetComponentInParent <StateController>();
            GameObject      enemy            = state_controller.gameObject;

            //divide damage by factor if the enemy is blocking

            if (state_controller.isBlocking == true)
            {
                damage = (int)(damage / blockMultiplier);
            }



            if (velocity.magnitude > 4)
            {
                if (other.gameObject.layer == 13 && collided == false)    //enemy layer is set to integer 13 in layer manager
                {
                    collided = true;
                    VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, haptic_strength, haptic_duration, 0.01f);
                    enemy.GetComponent <SkeletonDamagable>().DealDamage(damage);
                    Debug.Log("Damage dealt: " + damage);
                }
                else if (other.gameObject.layer == 12 && collided == false)      //critical layer is set to integer 12 in layer manager
                {
                    collided = true;
                    VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, haptic_strength, haptic_duration, 0.01f);
                    enemy.GetComponent <SkeletonDamagable>().DealDamage((int)(damage * critMultiplier));
                    Debug.Log("Crit damage dealt: " + damage);
                }
            }
        }
    }
Example #9
0
 public override void StartUsing(VRTK_InteractUse currentUsingObject)
 {
     base.StartUsing(currentUsingObject);
     if (Time.time > lastFire + fireDelay && pourWater.Use())
     {
         lastFire = Time.time;
         FireBullet();
         VRTK_ControllerHaptics.TriggerHapticPulse(
             VRTK_ControllerReference.GetControllerReference(ControllerEvents.gameObject), 0.63f, 0.2f, 0.01f);
     }
 }
Example #10
0
 private void InitEvent()
 {
     m_interTouch.ControllerTouchInteractableObject += (sender, e) =>
     {
         if (IsHaptic)
         {
             var controllerReference = VRTK_ControllerReference.GetControllerReference(gameObject);
             VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, m_strength, m_duration, m_pulseInterval);
         }
     };
 }
Example #11
0
    private void HandleWheelValueChanged(object sender, Control3DEventArgs e)
    {
        float valueDelta = Mathf.Abs(e.value - _previousValue);

        _currentCharge += valueDelta;
        _previousValue  = e.value;
        if (_controllerReference != null)
        {
            VRTK_ControllerHaptics.TriggerHapticPulse(_controllerReference, _windHapticStrength, 0.1f, 0.01f);
        }
    }
Example #12
0
 // Token: 0x06001DE2 RID: 7650 RVA: 0x00097F38 File Offset: 0x00096138
 public override void StartUsing(VRTK_InteractUse currentUsingObject)
 {
     base.StartUsing(currentUsingObject);
     if (this.safetySwitch.safetyOff)
     {
         this.slide.Fire();
         this.FireBullet();
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(this.controllerEvents.gameObject), 0.63f, 0.2f, 0.01f);
         return;
     }
     VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(this.controllerEvents.gameObject), 0.08f, 0.1f, 0.01f);
 }
Example #13
0
    // Trying to figure out how to use a poorly documented VRTK feature
    public void VibrateAudioClip(AudioClip audioClip)
    {
        // if running without headset
        if (_controller == null)
        {
            Debug.Log("not vibrating since no headset found");
            return;
        }

        Debug.Log("Vibration using audioclip " + audioClip.name);
        VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(_controller.controllerIndex), audioClip);
    }
Example #14
0
 public override void Grabbed(VRTK_InteractGrab grabbingObject)
 {
     base.Grabbed(grabbingObject);
     controllerReference = VRTK_ControllerReference.GetControllerReference(grabbingObject.controllerEvents.gameObject);
     if (VRTK_ControllerReference.IsValid(controllerReference) && IsGrabbed())
     {
         VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 0.5f, 0.5f, 0.01f);
         //strength, duration, pulse interval
         PlayAudio();
         //Glorious_Triumph
     }
 }
Example #15
0
        private void PullString()
        {
            currentPull = Mathf.Clamp((Vector3.Distance(holdControl.transform.position, stringControl.transform.position) - pullOffset) * pullMultiplier, 0, maxPullDistance);
            bowAnimation.SetFrame(currentPull);

            if (currentPull.ToString("F2") != previousPull.ToString("F2"))
            {
                VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(holdControl.gameObject), bowVibration);
                VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(stringControl.gameObject), stringVibration);
            }
            previousPull = currentPull;
        }
Example #16
0
 // Token: 0x06001D9B RID: 7579 RVA: 0x00096F90 File Offset: 0x00095190
 protected override void Update()
 {
     base.Update();
     if (this.controllerEvents)
     {
         float triggerAxis = this.controllerEvents.GetTriggerAxis();
         this.Spray(triggerAxis);
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(this.controllerEvents.gameObject), triggerAxis * 0.25f, 0.1f, 0.01f);
         return;
     }
     this.Spray(0f);
 }
Example #17
0
    private void SetNormaliserPosition()
    {
        if (interactableObject.IsGrabbed())
        {
            float offset = parentAxis.CalculateLinearMapping(interactableObject.GetGrabbingObject().transform);
            offset = Mathf.Clamp(offset, 0, 1);

            if (myDirection == 1)
            {
                if (isMinHandle)
                {
                    parentChart.XNormaliser = new Vector2(offset, parentChart.XNormaliser.y);
                }
                else
                {
                    parentChart.XNormaliser = new Vector2(parentChart.XNormaliser.x, offset);
                }
            }
            else if (myDirection == 2)
            {
                if (isMinHandle)
                {
                    parentChart.YNormaliser = new Vector2(offset, parentChart.YNormaliser.y);
                }
                else
                {
                    parentChart.YNormaliser = new Vector2(parentChart.YNormaliser.x, offset);
                }
            }
            else if (myDirection == 3)
            {
                if (isMinHandle)
                {
                    parentChart.ZNormaliser = new Vector2(offset, parentChart.ZNormaliser.y);
                }
                else
                {
                    parentChart.ZNormaliser = new Vector2(parentChart.ZNormaliser.x, offset);
                }
            }

            Vector3 newPos = Vector3.Lerp(parentAxis.MinPosition, parentAxis.MaxPosition, offset);
            newPos.x = initX;
            newPos.z = 0;
            transform.localPosition = newPos;
            transform.localRotation = storedRotation;

            storedPosition = newPos;

            VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(interactableObject.GetGrabbingObject()), 0.075f);
        }
    }
Example #18
0
 public void AttachArrow()
 {
     if (currentArrow == null)
     {
         currentArrow = Instantiate(arrowPrefab);
         currentArrow.transform.parent        = trackedObj.transform;
         currentArrow.transform.localPosition = new Vector3(0f, 0f, .342f);
         currentArrow.transform.localRotation = Quaternion.identity;
         //play spawn sound here
         arrowDamage.OnSpawn();
         VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 1f, .05f, .05f);
     }
 }
Example #19
0
 private void OnCollisionEnter(Collision collision)
 {
     if (VRTK_ControllerReference.IsValid(controllerReference) && IsGrabbed())
     {
         collisionForce = VRTK_DeviceFinder.GetControllerVelocity(controllerReference).magnitude *impactMagnifier;
         var hapticStrength = collisionForce / maxCollisionForce;
         VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, hapticStrength, 0.5f, 0.01f);
     }
     else
     {
         collisionForce = collision.relativeVelocity.magnitude * impactMagnifier;
     }
 }
Example #20
0
    protected override void OnHurt(int amount)
    {
        AkSoundEngine.PostEvent(akEventHurt, this.gameObject);
        UpdateHUD();

        GameObject Lcontroller = VRTK_DeviceFinder.GetControllerLeftHand();
        GameObject Rcontroller = VRTK_DeviceFinder.GetControllerRightHand();
        VRTK_ControllerReference LcontrollerReference = VRTK_ControllerReference.GetControllerReference(Lcontroller);
        VRTK_ControllerReference RcontrollerReference = VRTK_ControllerReference.GetControllerReference(Rcontroller);

        VRTK_ControllerHaptics.TriggerHapticPulse(LcontrollerReference, haptic_strength, haptic_duration, 0.005f);
        VRTK_ControllerHaptics.TriggerHapticPulse(RcontrollerReference, haptic_strength, haptic_duration, 0.005f);
    }
Example #21
0
    private IEnumerator TriggerHapticPulse()
    {
        while (_isMoving)
        {
            var hapticPulseStrength = GetComponent <Magnet>().getExternalForce().magnitude / 10;

            VRTK_ControllerHaptics.TriggerHapticPulse(
                VRTK_ControllerReference.GetControllerReference(_grabbingObject),
                hapticPulseStrength);

            yield return(new WaitForFixedUpdate());
        }
    }
Example #22
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.relativeVelocity.magnitude > 2)
        {
            var randomAudioClip = AudioClips[random.Next(AudioClips.Length)];
            audioSource.clip = randomAudioClip;
            audioSource.Play();

            if (currentlyHeld)
            {
                VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controller.gameObject), randomAudioClip);
            }
        }
    }
Example #23
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);
     }
 }
Example #24
0
 public override void StartUsing(VRTK_InteractUse currentUsingObject)
 {
     base.StartUsing(currentUsingObject);
     if (safetySwitch.safetyOff)
     {
         slide.Fire();
         FireBullet();
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject), 1f, 0.1f, 0.01f);
     }
     else
     {
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject), 0.5f, 0.1f, 0.01f);
     }
 }
Example #25
0
    private void OnTriggerEnter(Collider other)
    {
        if (isErasing)
        {
            if (other.gameObject.tag == "Line")
            {
                LineScript line = other.GetComponent <LineScript>();
                DataLogger.Instance.LogActionData(this, line.OriginalOwner, line.photonView.Owner, "Line erased", line.ID);

                PhotonNetwork.Destroy(other.gameObject);

                VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(interactableObject.GetGrabbingObject()), 0.3f);
            }
        }
    }
Example #26
0
    private void OnTriggerEnter(Collider collider)
    {
        if (saberCollisionVibrationLevel > 0)
        {
            if (collider.CompareTag("Saber"))
            {
#if UNITY_ANDROID
                var controller = controllerReference.actual.GetComponent <QuestHapticFeedback>();
                StartCoroutine(controller.HapticPulse(0.5f, 0.01f, 0.0f, saberCollisionVibrationLevel / 10.0f, true));
#else
                VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 0.4f, 10000.0f, 0.01f);
#endif
            }
        }
    }
Example #27
0
        // バイブレーション
        public void HapticPulse(int side)
        {
            VRTK_ControllerReference cr;

            if (side == 0)
            {
                cr = rightControllerReference;
            }
            else
            {
                cr = leftControllerReference;
            }

            VRTK_ControllerHaptics.TriggerHapticPulse(cr, 1.0f);
        }
Example #28
0
 private void FireBullet()
 {
     if (bulletShot < MagazineSize)
     {
         GameObject bulletClone = Instantiate(bullet, bullet.transform.position, bullet.transform.rotation) as GameObject;
         gunSound.Play();
         bulletClone.SetActive(true);
         Rigidbody rb = bulletClone.GetComponent <Rigidbody>();
         rb.AddForce(bullet.transform.forward * bulletSpeed);
         Destroy(bulletClone, bulletLife);
         muzzleFlash.Play();
         VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject), 1f, 0.2f, 0.01f);
         bulletShot++;
         GameManager.instance.updateAmmoCount(bulletShot);
     }
 }
Example #29
0
 private void OnCollisionEnter(Collision collision)
 {
     Debug.Log("Hammer Collided with something=" + collision.collider.name);
     if (VRTK_ControllerReference.IsValid(controllerReference) && IsGrabbed())
     {
         collisionForce = VRTK_DeviceFinder.GetControllerVelocity(controllerReference).magnitude *impactMagnifier;
         var hapticStrength = collisionForce / maxCollisionForce;
         VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, hapticStrength, 0.4f, 0.01f);
         AudioSource audio = GetComponent <AudioSource> ();
         audio.Play();
     }
     else
     {
         collisionForce = collision.relativeVelocity.magnitude * impactMagnifier;
     }
 }
Example #30
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
     {
     }
 }