Search Unity

Getting HTC Vive Controllers Best Practice

Discussion in 'Scripting' started by lauchsuppe, Aug 18, 2017.

  1. lauchsuppe

    lauchsuppe

    Joined:
    Dec 6, 2014
    Posts:
    39
    How do I create a reference to the HTC Vive Controllers in my Unity scene? They are loaded only after start and a couple of updates away. Currently, I'm running through Update() for until my other script finds them in the scene - but that is not a good practice.
    How can I create a reference to these controllers once they are loaded in the scene?
     
  2. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    1) Create a VR controller manager. This manager is responsible for checking for when the HTC controllers become active and available.

    2) This manager fires off an event when a controller is detected and added to its cache.

    3) Other scripts register a callback with the manager so they get notified when a controller is loaded and becomes active.
     
    lauchsuppe likes this.
  3. lauchsuppe

    lauchsuppe

    Joined:
    Dec 6, 2014
    Posts:
    39
    Oh, I didn't know there was a class for that. Thanks for pointing it out!
    Anyway, is there a comprehensive steamvr documentation somewhere? Stuff like e.g. event subscription is new to me and thus I'm a little overwhelmed by the steamvr sdk's complexity. It would be cool to have an API similar to the one Unity has where every little thing is explained. Is there something like that?
    https://developer.valvesoftware.com/wiki/SteamVR or https://github.com/ValveSoftware/openvr/wiki/API-Documentation don't seem to go into detail about all the classes and functions the steamvr sdk has to offer.