Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Haptic Feedback for HTC Vive... (SteamVR_Controller does not exist...)

Discussion in 'VR' started by tytang24, Oct 3, 2018.

  1. tytang24

    tytang24

    Joined:
    Oct 3, 2018
    Posts:
    1
    Hello... I really tried my hardest to avoid asking this because it seems like such a dumb question, but I cannot for the life of me get haptic feedback working in Unity. The issue stems from not being able to find SteamVR_Controller in the namespace...

    I really don't know why this is happening or what's going on. I figured it was the newest version of Unity/SteamVR that caused the problem and there was some new way to do it, but I really am about to throw my computer out the window.

    I have the SteamVR plugin and SteamVR is installed. I don't have any problems using the camerarig and the controllers are being picked up correctly. Please, please help me and save me from going insane.

    Code (CSharp):
    1. using UnityEngine;
    2. using Valve.VR;
    3. using Valve.VR.InteractionSystem;
    4.  
    5. public class VibrateOnTouch : MonoBehaviour
    6. {
    7.  
    8.     public SteamVR_Controller;
     
  2. tonnynevel

    tonnynevel

    Joined:
    Oct 19, 2018
    Posts:
    2
    i have same problem, using latest 2018.2.12f1 and SteamVR, looked as they just delete this SteamVR_Controller script and i really did not know how to use it now, all tutorials based on it. In older versions i find this script, but when you drag&drop it in new project it cause too much errors. So if somebody know how to solve it you will save 2 PC from being dropped from window.
     
  3. elaine_jiang

    elaine_jiang

    Joined:
    Sep 25, 2018
    Posts:
    1
    I'm having the same problem!!! There aren't any examples in the documentation, so it's been super frustrating. :(

    Has anyone figured it out?
     
  4. zvidrih

    zvidrih

    Joined:
    Jan 31, 2017
    Posts:
    4
    Hi,

    as you guys I've been quite surprised to see that most of the things have been turned upside down in Unity steamvr. Anyway, i think i have a quick solution, which works for me for now.

    Controllers have SteamVR_Behaviour_Pose scripts which don't include output by default, so I've just added a SteamVR_Action_Vibration to them

    Code (CSharp):
    1. [SteamVR_DefaultAction("Haptic")]
    2. public SteamVR_Action_Vibration hapticSignal;
    and in editor set hapticSignal to \actions\default\out\Haptic (attachment)

    then you can simply trigger the haptic commands by calling

    Code (CSharp):
    1. SteamVR_Action_Vibration.Execute(float secondsFromNow, float durationSeconds, float frequency, float amplitude, SteamVR_Input_Sources inputSource)
    where inputSource comes from the SteamVR_Behaviour_Pose.

    after that instead of "controller" use the SteamVR_Behaviour_Pose controller

    e.g.

    Code (CSharp):
    1. controller.hapticSignal.Execute(0f, 0.1f, 160, 0.5f, controller.inputSource);
    Hope it helps.
     

    Attached Files:

  5. kjohnsen1

    kjohnsen1

    Joined:
    Jan 4, 2015
    Posts:
    2
    From my testing with the Oculus Touch on Steam VR, using Unity 2018.2.16f1

    delay - does nothing (set to anything)
    duration - Anything <= .79f works. 0 also works for a short pulse. You need to set > 0 to really feel the other things
    frequency - up to 320 works, and can be felt as long as duration > 0. Don't set Freq == 0, will crash system
    amplitude - up to ~.25f can be felt, after that, it's full strength.
     
  6. CDrik_

    CDrik_

    Joined:
    Jun 5, 2018
    Posts:
    1
    Thank you so much !
     
  7. heatondev

    heatondev

    Joined:
    May 6, 2017
    Posts:
    1
    DefaultAction attribute seems to be gone in the latest update. Anyone else have haptics working?
     
  8. EyePD

    EyePD

    Joined:
    Feb 26, 2016
    Posts:
    35
    I followed these guides and the haptics displayed as if they were activated in the SteamVR Input Live View but I could not get my controllers (Knuckles EV3) to actually vibrate. I was in a hurry so I decided to just use the built-in UnityXR haptics and they worked fine:

    Code (CSharp):
    1. InputDevice device = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
    2. HapticCapabilities capabilities;
    3. if(device.TryGetHapticCapabilities(out capabilities))
    4. {
    5.     if(capabilities.supportsImpulse)
    6.     {
    7.         uint channel = 0;
    8.         float amplitude = 0.5f;
    9.         float duration = 1.0f;
    10.         device.SendHapticImpulse(channel, amplitude, duration);
    11.     }
    12. }