1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Collections;
- using UnityEngine;
- using Valve.VR;
- public class ViveControllerHit : MonoBehaviour
- {
- private void Start()
- {
- this.m_trackedObject = base.transform.parent.GetComponent<SteamVR_TrackedObject>();
- NDebug.Assert(this.m_trackedObject != null, "SteamVR_TrackedObject が親から取得不可能。");
- }
- private void Update()
- {
- }
- private void OnCollisionEnter(Collision collision)
- {
- this.m_device = SteamVR_Controller.Input((int)this.m_trackedObject.index);
- if (this.m_device != null)
- {
- base.StartCoroutine(this.CoVive());
- }
- }
- private IEnumerator CoVive()
- {
- for (float fTime = 0f; fTime < this.m_fViveTimeMS; fTime += Time.deltaTime)
- {
- yield return null;
- this.m_device.TriggerHapticPulse(this.m_uViveForce, EVRButtonId.k_EButton_Axis0);
- }
- yield break;
- }
- public ushort m_uViveForce = 1000;
- public float m_fViveTimeMS = 0.1f;
- private SteamVR_TrackedObject m_trackedObject;
- private SteamVR_Controller.Device m_device;
- }
|