Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity wants to learn about your experiences working on a Unity project today. We'd like to hear from you via this survey.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  4. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

[SteamVR] Trigger HTC Controller's input by script

Discussion in 'AR/VR (XR) Discussion' started by HRV-Simulation, Aug 3, 2017.

  1. HRV-Simulation

    HRV-Simulation

    Joined:
    Oct 27, 2016
    Posts:
    6
    Hello, I would like to know how can I simulate controllers inputs from a csharp script.
    My goal is to trigger input events like 'Grip', 'Trigger' or 'Pad' pressed without using the real HTC controller and for example, call these events from the keyboard. Exactly like the "NoSteamVRFallback" system the simulate controller's actions with the mouse.

    For now I can only simulate the Trigger button using "GetStandardInteractionButton()" function within the Hand script. Instead of GetMouse, I just use GetKey(something). But it's obviously not the right way to get this works properly without modifying the steamvr_plugin's script.

    PS : I'm using the last version of the plugin and I don't want to use VRTK for this. So thanks in advance for your help :)
     
  2. peterept2

    peterept2

    Joined:
    Aug 1, 2012
    Posts:
    41
    What you want is to use the Unity Input mapping, see here:

    https://docs.unity3d.com/Manual/OpenVRControllers.html

    So, for example, Trigger press (not touch) on Right Vive Controller (or Oculus Touch) is Unity Axis 10. So you go into Edit->Project Settings->Input and add a new input entry. Name it whatever, say "openvr-r-trigger-press", and for type choose "Joystick Axis" and for axis choose "10th". Now, to simulate with a key, under positive button put, say "z".

    Now, in your script, call Input.GetAxis("openvr-r-trigger-press") and if the value is > 0.1f say then it's pressed.

    If you press Z it will work, and if you have a real controller it will also work.
     
  3. HRV-Simulation

    HRV-Simulation

    Joined:
    Oct 27, 2016
    Posts:
    6
    Unfortunately I can't do it this way. My goal is to interact with native SteamVR components like "Throwable", "Interactable" or the teleportation system using "Hand' component with a device that isn't a HTC Controller (I wanna use a bluetooth remote tracked with an infra-red motion capture system within a CAVE).

    But I don't want to code my own overlay like VRTK or NewtonVR, I just want to keep it as simple as possible ^^. Isn't there a way to throw events ?

    Within the SDK, a "No SteamVR fallback" system does exist but it works only with the Trigger button using "Hand.GetStandardInteractionButtonDown()" to check if the mouse button was clicked.
     
    kbabilinski likes this.
  4. asm16

    asm16

    Joined:
    Nov 12, 2018
    Posts:
    1
    Did you ever make any progress with this? I've been attempting the same thing (even trying with VRTK) and I've still not been able to achieve interactability.
     
  5. emmettbebop

    emmettbebop

    Joined:
    Apr 26, 2018
    Posts:
    3
  6. Licenses-SeriousVR

    Licenses-SeriousVR

    Joined:
    Jan 2, 2018
    Posts:
    1
    Bump! Has anybody managed to do this yet? I am trying to emulate the OnTriggerDown Event of VRTK without actually pressing the trigger on a physical controller, but via script
     
  7. MrJohnWeez

    MrJohnWeez

    Joined:
    Aug 31, 2013
    Posts:
    8
    Has anyone had any luck figuring this out?
     
unityunity