public override void StartUsing(VRTK_InteractUse currentUsingObject) { base.StartUsing(currentUsingObject); if (bulletsLeftInClip > 0) { slide.Fire(); FireBullet(); if (ammoTooltip != null) { ammoTooltip.UpdateText(bulletsLeftInClip + " / " + bulletClipSize); } bulletsLeftInClip--; VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject), 0.63f, 0.2f, 0.01f); } else { slide.needsReloading = true; if (ammoTooltip != null) { ammoTooltip.UpdateText("Reload"); } } }
private void Pulse() { _pulsing = true; Time.timeScale = _originalTimeScale * _minTimeScalePercent; Physics.gravity = _originalGravity * _minGravityPercent; _gravityOverridden = false; if (_disableGravityPercent > 0) { _gravityOverridden = true; } for (int i = 0; i < _rigidbodyData.Length; ++i) { Vector3 direction = transform.position - _rigidbodyData[i].rigidbody.transform.position; if (_gravityOverridden) { _rigidbodyData[i].rigidbody.useGravity = false; } _rigidbodyData[i].rigidbody.AddForce(direction * _pullForce * _rigidbodyData[i].rigidbody.mass); } if (_controllerReference != null) { VRTK_ControllerHaptics.TriggerHapticPulse(_controllerReference, _pulseHapticStrength, 0.2f, 0.01f); } }
public void OnTouched(object sender, ObjectInteractEventArgs e) { if (isTouch == true) { return; } //Debug.Log("OnTouched"); isTouch = true; Invoke("TouchChanged", 1f); curAxisX += 30f; Debug.Log("curAxisX =" + curAxisX); if (curAxisX >= maxAxisX) { curAxisX = maxAxisX; this.gameObject.SetActive(false); room.SetActive(true); light2.gameObject.SetActive(true); light3.gameObject.SetActive(true); RenderSettings.skybox = skybox; plane.SetActive(false); particle.SetActive(false); voice2.SetActive(true); } light.transform.eulerAngles = new Vector3(curAxisX, 0, 0); //添加手柄震动效果 VRTK_ControllerReference controllerReference = new VRTK_ControllerReference(SDK_BaseController.ControllerHand.Right); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 1f, 0.3f, 0.01f); }
IEnumerator StartHapticUntilUnused(GameObject usingObj) { VRTK_ControllerReference controllerReference = VRTK_ControllerReference.GetControllerReference(usingObj); while (InterObject.IsUsing()) { VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, hapticPulseStrength, hapticPulseDuration, hapticPulseInterval); yield return(waitForJudgeIfBeingUsed); } var lastTime = 5; for (int i = 0; i <= lastTime; i++) { float currentStrengh = Mathf.Lerp(hapticPulseStrength, 2 * hapticPulseStrength / 3, (float)i / lastTime); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, currentStrengh, hapticPulseDuration, hapticPulseInterval); yield return(new WaitForSeconds(0.05f)); } //-------------------------------------------- for (int i = 0; i <= lastTime; i++) { float currentStrengh = Mathf.Lerp(2 * hapticPulseStrength / 3, 0, (float)i / lastTime); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, currentStrengh, hapticPulseDuration, hapticPulseInterval); yield return(new WaitForSeconds(0.05f)); } }
private void PlayHapticTick() { //Use hand opposite the target hand for haptic feedback SDK_BaseController.ControllerHand hapticHand = targetHand == SDK_BaseController.ControllerHand.Right ? SDK_BaseController.ControllerHand.Left : SDK_BaseController.ControllerHand.Right; VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(hapticHand), TickStrength); }
// Update is called once per frame void Update() { if (controllerReference == null) { return; } if (rigidbody_held == true) { Vector3 velocity = VRTK_DeviceFinder.GetControllerVelocity(controllerReference); controller_speed = velocity.magnitude; if (controller_speed >= 1) { float scale_factor = controller_speed / max_controller_speed; haptic_strength = Mathf.Lerp(0, 1, scale_factor); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, haptic_strength, haptic_duration, haptic_delay); } } else { if (rb.velocity.magnitude >= 1) { float scale_factor = rb.velocity.magnitude / max_rb_speed; haptic_strength = Mathf.Lerp(0, 1, scale_factor); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, haptic_strength, haptic_duration, haptic_delay); } } }
public void OnUIPointerElementClick(object sender, UIPointerEventArgs e) { //添加手柄震动效果 VRTK_ControllerReference controllerReference = new VRTK_ControllerReference(SDK_BaseController.ControllerHand.Right); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 0.1f, 0.1f, 0.01f); }
private void TurnOn() { m_waterParticleSystem.Play(); m_controller = VRTK_ControllerReference.GetControllerReference(m_controllerEvents.gameObject); VRTK_ControllerHaptics.TriggerHapticPulse(m_controller, m_hapticStrenght, float.PositiveInfinity, m_hapticInterval); m_soundEmitter.Play(); }
public void CancelControllerVibrations() { Debug.Log("Vibration cancelled"); VRTK_ControllerHaptics.CancelHapticPulse(VRTK_ControllerReference.GetControllerReference(LeftController)); VRTK_ControllerHaptics.CancelHapticPulse(VRTK_ControllerReference.GetControllerReference(RightController)); isVibrating = false; }
public override void OnValueChanged(UnityEngine.Object sender, KaiKnobEventArgs e) { base.OnValueChanged(sender, e); var controllerReference = VRTK_ControllerReference.GetControllerReference(m_interUse.gameObject); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, Mathf.Abs(m_currentValue - m_previousValue) * m_hapticCoefficient); }
void RepeatPulse() { VRTK_ControllerHaptics.TriggerHapticPulse( VRTK_ControllerReference.GetControllerReference(LeftHand.gameObject), 0.63f, 0.2f, 0.01f); VRTK_ControllerHaptics.TriggerHapticPulse( VRTK_ControllerReference.GetControllerReference(RightHand.gameObject), 0.63f, 0.2f, 0.01f); }
protected virtual void OnCollisionEnter(Collision collision) { // This means that the weapon is thrown and hit a surface if (inFlight) { OnHitSurface(collision.transform); CheckIfEnemyAndDealDamage(collision, collision.contacts[0].point, velocity); inFlight = false; } if (twoHanded) { velocity *= 3; } if (VRTK_ControllerReference.IsValid(controllerReference) && IsGrabbed() && velocity > 8) { collisionForce = VRTK_DeviceFinder.GetControllerVelocity(controllerReference).magnitude *impactMagnifier; var hapticStrength = collisionForce / maxCollisionForce; VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, hapticStrength, 0.5f, 0.01f); CheckIfEnemyAndDealDamage(collision, collision.contacts[0].point, velocity); AudioManager.instance.PlayClip(AudioManager.SoundFX.Impact, transform.position); } }
private void DoHaptics() { if (controllerReference != null) { VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, mcClippySound); } }
protected void ResizeWater(float distance) { fillWater.localPosition = new Vector3(beginPositionWater.x, beginPositionWater.y, beginPositionWater.z - (distance / 2)); fillWater.localScale = new Vector3(fillWater.localScale.x, distance / 2, fillWater.localScale.z); lcdCanvas.gameObject.SetActive(true); float accurateValue = (distance / maxMove) * syringeValue; if (accurateValue < 0.5f) //gets rid of rounding errors: { accurateValue = 0; } else if (accurateValue > (syringeValue - 0.5f)) { accurateValue = syringeValue; } valueF = ((Mathf.Round(accurateValue * 2)) / 2.0f); string value = valueF.ToString("F2"); Debug.Log("Value Syringe: " + valueF + " accurate value : " + accurateValue); if (value == "0.00") //if syringe is empty clear medication it has pulled { pulledMedicine.Clear(); Debug.Log("Medication in syringe cleared!"); } lcdText.text = value + " ml"; if (float.Parse(value) % 1 == 0) //this should buzz every ml { VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(GetUsedHand()), 0.5f, 0.2f, 0.5f); } }
// Update is called once per frame void Update() { controllerReference = VRTK_ControllerReference.GetControllerReference(controller.gameObject); Debug.Log(controllerReference); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 1f, 0.5f, 0.01f); }
// Update is called once per frame void Update() { if (photonView.IsMine) { if (Input.GetKeyDown(KeyCode.K)) { SetupControllersIfNecessary(); VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controller_right), 15f, 0.5f, 0.01f); } if (Input.GetKeyDown(KeyCode.L)) { SetupControllersIfNecessary(); VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controller_left), 10f, 1f, 0.02f); } if (!broadcastToAllOthers) { if (Input.GetKeyDown(keyMapping[0].ToString())) { this.photonView.RPC("BroadcastHapticPulse", RpcTarget.All); } } if (broadcastToAllOthers) { if (Input.GetKeyDown(keyMapping[0].ToString())) { this.photonView.RPC("BroadcastHapticPulse", RpcTarget.Others); } } } }
protected virtual void AttemptHapticPulse(float strength) { if (events) { VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(events.gameObject), strength); } }
void OnCollisionEnter(Collision col) { //当Collision/Rigidbody触发另一个时调用 GameObject victim = col.collider.gameObject; //若没有方块属性则返回 if (!victim.GetComponent <Cube>()) { return; } CutCube(col); if (IsCutCorrect(col)) { //切割成功时 GLOBAL_PARA.Game.CutCorrect(); AudioSource.PlayClipAtPoint(correctTrriger, victim.transform.position); //Debug.Log(victim.transform.position.z); //VRTK震动反馈 VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(transform.parent.gameObject), hapticForce); } else { //切割失败时 GLOBAL_PARA.Game.RefreshCombo(); //TODO 目前声音太大,需要在实际运行时调整音量 AudioSource.PlayClipAtPoint(errorTrriger, victim.transform.position, 0.5f); //VRTK震动反馈 VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(transform.parent.gameObject), 1.5f * hapticForce); } }
private void Activate() { m_controller = VRTK_ControllerReference.GetControllerReference(m_controllerEvents.gameObject); VRTK_ControllerHaptics.TriggerHapticPulse(m_controller, m_hapticStrenght, float.PositiveInfinity, m_hapticInterval); //m_windParticles.transform.SetParent(null, false); m_soundEmitter.Play(); }
private void DeactivateGarbageEffects() { m_particleSucker.enabled = false; m_soundEmitter.SetParameter(m_garbageParamName, 0); m_suckingGarbage = false; VRTK_ControllerHaptics.TriggerHapticPulse(m_controller, m_hapticStrenght, float.PositiveInfinity, m_hapticInterval); }
/// <summary> /// the function to play a haptic pulse if the player isnt using a vive. (haptics were broken on the vive) TODO: find out which the vive haptics sound wrong. /// </summary> void TriggerHapticPulse() { Debug.Log("hapticpulse"); if (ViveObject == null || ViveObject.GetActive() == false) { VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerIndex(this.gameObject)), audioahptic); } }
private void Haptic() { if (m_interactController) { var controllerReference = VRTK_ControllerReference.GetControllerReference(m_interactController); VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 1f, 0.2f, 0.1f); } }
void OnTriggerEnter(Collider collider) { VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerObject), 1); if (collider.tag.Equals("Breakable")) { collider.GetComponent <BreakableObject>().DoBreak(); } }
IEnumerator DoPulsing() { while (gameObject.activeSelf) { VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, 0.5f, pulseDuration, 0.01f); yield return(new WaitForSeconds(pulseInterval)); } }
public override void StartUsing(VRTK_InteractUse currentUsingObject) { base.StartUsing(currentUsingObject); slide.Fire(); //FireBullet(); fireRaycast(); VRTK_ControllerHaptics.TriggerHapticPulse(VRTK_ControllerReference.GetControllerReference(controllerEvents.gameObject), 0.63f, 0.2f, 0.01f); }
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); } }
protected virtual void TriggerHapticPulse(VRTK_ControllerReference controllerReference) { if (VRTK_ControllerHaptics.TriggerHapticFrequency(controllerReference, amplitude, duration, frequency)) { return; } VRTK_ControllerHaptics.TriggerHapticPulse(controllerReference, strengthOnTouch, durationOnTouch, (intervalOnTouch >= minInterval ? intervalOnTouch : minInterval)); }
private void TurnOff() { if (m_controller != null) { VRTK_ControllerHaptics.CancelHapticPulse(m_controller); } m_waterParticleSystem.Stop(); m_soundEmitter.Stop(); }
private void Io_InteractableObjectUngrabbed(object sender, InteractableObjectEventArgs e) { CancelInvoke("DoHaptics"); if (controllerReference != null) { Debug.Log(VRTK_DeviceFinder.GetControllerVelocity(controllerReference)); VRTK_ControllerHaptics.CancelHapticPulse(controllerReference); } controllerReference = null; }
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; }