public override bool SetRumble(XRControllerRumbleSide controller, float strength, float duration) { if (strength < 0) { strength = 0; } if (strength > 1) { strength = 1; } if (duration < 0) { duration = 0; } if (leftHand >= 0 && (controller == XRControllerRumbleSide.Left || controller == XRControllerRumbleSide.Both)) { input.TriggerHapticVibrationAction(viveAction_Rumble_LeftHand, 0, duration, 1, strength, 0); } if (rightHand >= 0 && (controller == XRControllerRumbleSide.Right || controller == XRControllerRumbleSide.Both)) { input.TriggerHapticVibrationAction(viveAction_Rumble_RightHand, 0, duration, 1, strength, 0); } return(true); }
//---------------アクション設定系------------------- //振動を発生させる public void TriggerHaptic(string ActionPath, float StartTime, float DurationTime, float Frequency, float Amplitude, string RestrictToDevicePath = "") { ReadyCheck(); //実行可能な状態かチェック EVRInputError inputError = EVRInputError.None; ulong handle = GetActionHandle(ActionPath); //無効なハンドルならthrowされる //制約デバイス指定されていれば適用 ulong DeviceHandle = OpenVR.k_ulInvalidInputValueHandle; if (RestrictToDevicePath != "") { DeviceHandle = GetInputSourceHandle(RestrictToDevicePath); //無効なハンドルならthrowされる } //取得処理 inputError = vrinput.TriggerHapticVibrationAction(handle, StartTime, DurationTime, Frequency, Amplitude, DeviceHandle); if (inputError == EVRInputError.WrongType) { //姿勢ではない throw new ArgumentException(inputError.ToString()); } if (inputError != EVRInputError.None) { //致命的エラー throw new IOException(inputError.ToString()); } return; }