ViveInputUtility-Unity icon indicating copy to clipboard operation
ViveInputUtility-Unity copied to clipboard

Vibrate the controller and no effect

Open fishsama opened this issue 8 years ago • 11 comments

Version of Unity3D : 5.5.2f1 & 2017.1.1f1 Version of ViveInputUtility : 1.7.3

Question : I want to trigger the vibration of the controller by using the api called "ViveInput.TriggerHapticPulse" but there is no effect. I have read the VRModuleManager and checked out the "m_activatedModuleBase" is UnityEngineVRModule, the method "TriggerViveControllerHaptic" is a virtual method and there is no implementation in UnityEngineVRModule. So I feedback this situation, or is there something wrong in my project setting?

fishsama avatar Dec 20 '17 10:12 fishsama

Hi Fishsama,

Currently you still need the SteamVR plugin for haptics The new new Input System from Unity is still a work in progress and we'll add support asap.

dariol avatar Dec 20 '17 18:12 dariol

Got it, thanks

fishsama avatar Dec 22 '17 01:12 fishsama

Hi! Could you please suggest me which part of the SteamVR plugin I have to include to let the vibration works properly? (if possible, I don't want to include the entire plugin) Thanks!

NickZangus avatar Feb 14 '18 16:02 NickZangus

this is very cool ,thank you!

CGDriverLi avatar Feb 21 '18 07:02 CGDriverLi

@NickZangus Sorry, actually I have changed the plan when got that news, so I haven't tried to use steamVR.

fishsama avatar Feb 27 '18 06:02 fishsama

To resolve the issue. you just import steam plugin from unity assetstore then call ViveInput.TriggerHapticPulse(HandRole.LeftHand); , and evething will be fine;

Zvirtuosity avatar Jul 05 '18 02:07 Zvirtuosity

@NickZangus

Zvirtuosity avatar Jul 05 '18 02:07 Zvirtuosity

Hi guys, Hi @Zvirtuosity

I imported SteamVR plugin, used ViveInput.TriggerHapticPulse(HandRole.LeftHand);

But there is still no effect

I ve noticed the VIU_STEAMVR_1_2_3_OR_NEWER in the compile header

To be sure that the compile header was taken in account, I forced the recompilation. But still no vibration on the controllers :(

Do you have any idea why ? I have version 1.9 and Unity 2017.4.14f1

Edit :

I found the solution, thanks to @chengnay, we need to use a previous version of SteamVR while the team is working on the issue. https://github.com/ViveSoftware/ViveInputUtility-Unity/issues/54#issue-363904294

Shocoben avatar Nov 15 '18 20:11 Shocoben

For anyone else having issues this took me awhile to figure out too especially since a lot of things were updated/outdated since the last time I touched this.

Currently I'm running Unity 2018.2.16f1, SteamVR Plugin 2.0.1, and the Vive Input Utility from the improve/steamvr200support branch at https://github.com/ViveSoftware/ViveInputUtility-Unity/tree/improve/steamvr200support

To trigger haptic feedback ViveInput.TriggerHapticPulse(HandRole.LeftHand); still doesn't work but what I did as a test was created a new script and added the following in:

using UnityEngine;
using Valve.VR;

public class ControllerFeedback : MonoBehaviour
{
    [SteamVR_DefaultAction("Haptic")]
    public SteamVR_Action_Vibration hapticAction;
    public float microSecondsDuration = 1000;
    public SteamVR_Input_Sources handType;
  
    private void OnCollisionEnter(Collision collision)
    {
        float seconds = (float)microSecondsDuration / 1000000f;
        hapticAction.Execute(0, seconds, 1f / seconds, 1, handType);
    }
}

This triggers the haptics fine, just make sure in the inspector you set the Haptic Action to "\actions\default\out\Haptic" assuming you've set up the SteamVR Inputs.

(I'm building a project off of the Vive Input Utility and I've only imported SteamVR for the haptic feedback as an fyi)

tvledesign avatar Dec 01 '18 21:12 tvledesign

I fixed haptics problem and pushed the latest commit d6223377f9b12cb8cafdd7dfb7bd4f15df84f899 Also add new input API:

ViveInput.TriggerHapticVibrationEx<TRole>(
    TRole role,
    float durationSeconds = 0.01f,
    float frequency = 85f,
    float amplitude = 0.125f,
    float startSecondsFromNow = 0f)

Notice that this commit have added new actions, so you need to apply VIU Action Set again. Let us know if it works! Thanks!

lawwong avatar Jan 17 '19 11:01 lawwong

@lawwong Thanks a lot, i will try it later

fishsama avatar Apr 18 '19 02:04 fishsama