How to fix controllers buttons not working and menu interactions with Vive Wave SDK 3.0 in Unity
I was porting our Unity game Hit Motion: Reloaded to the new Vive Wave SDK 3.0.2 so that to make it ready for launch on the Vive Focus Plus, when something made me panic: no button on the controllers was working! I wrote to HTC and in the end, I managed to someway solve the issue… so I am writing this post for everyone that may find him/herself in the same situation.
How to make controllers’ buttons to work in Unity with Vive Wave SDK 3.0?
The situation is this one: you have made your Vive Wave project, everything seems so fine and in the Editor the game works like a charm. Then you push it on your Vive Focus Plus, with a smile on your face… to discover that the controllers are just like two magic wands that are tracked perfectly, but no button seems to work.
So you open the Vive Wave SDK Samples, you look at the Controller6DofTest scene, and you see that your program is identical to that… and in fact, if you build that sample scene, it doesn’t work either.
So… what to do? Or, as Chinese people would say: 我们怎么办?
I asked this to Tony Lin of HTC and he kindly pointed me towards the solution. This strange behavior is due to a new feature that HTC is introducing in the Vive Wave SDK, called “Auto Key Mapping”, that will be useful to create automatic mappings of button commands among all the Vive Wave headsets. To implement this great stuff, the SDK has been modified and in this new version, you are now required to call a new API about the input. As the release notes of the Vive Wave SDK report:
WVR_SetInputRequest MUST be invoked after WVR_Init otherwise the app can NOT receive any key events from WAVE SDK 3.0 and later. To see detail.
So, basically, you have to call at first WVR_Init and then WVR_SetInputRequest to make everything work. There is only one problem… where the heck should I to invoke those functions??
Because yes, we are in Unity, and that line is referred to the native C++ SDK. And in Unity, all the Wave initializations are usually not performed by hand…
Luckily, there is another sample scene that may help us and this scene is “Button_test”. Inside it, you can see a prefab called WaveVRButtons, that has attached to it a script called WaveVR_ButtonList. If you give a look to the code of WaveVR_ButtonList, you will notice that it actually calls WVR_SetInputRequest… and this will happen after the WVR_Init call that is instead performed by the main WaveVR prefab. So, this is the magic script that will call the above native API for us and will make everything work.
So, how to make everything to work again?
- Add an empty
gameobject to the first scene of your experience; - Add to this object the script WaveVR_ButtonList.You can find it in the Assets\WaveVR\Scripts folder;
- In the inspector, specify in this script what kind of buttons you want to be tracked for the dominant (usually, the right) and non-dominant (usually, the left) controllers;
- Enjoy your program working again;
- Thank Skarredghost giving him $1000.
This trick has been a life saver for me. Notice that you need to use this script only once at the beginning of the program, it doesn’t need to be in every scene that you have (unless you want to change the settings).
How to make the controllers point correctly at menu items in Vive Wave?
Bonus tip, for another thing that has driven me crazy for
These days, I have finally discovered the reason. By default, the Wave SDK uses a pointing mechanism called “Mouse”. This pointing mechanism works this way: you have the controllers casting a ray from them and on this ray, at 1 meter of distance from each controller, you have a little dot, called the “Pointer”. If the line of sight going from your eyes to the Pointer crosses a UI
Needless to say, this is a bit unusual. I’ve made people from Italy,
To change this, you have just to change the pointing mechanism to “Beam”. The “Beam” mode will actually cast a ray from the
- If you are using menus that interact with the controllers, you have already for sure added the InputModuleManager prefab to your scene. If not, add it;
- Select the prefab and in the Inspector, look at its WaveVR_InputModuleManager script;
- Check the Override System Settings box;
- Find the field “Raycast Mode” and select “Beam”;
- Be happy and see your users being able to use a menu again.
Of course, this is only one of the possible approaches… here we are forcing this setting. The other possibility is to directly change the System Settings of the device.
I hope this little post will save some headaches to some Vive Wave devs… and if this has been the case for you, like and share this post!
(Header image by HTC)
Disclaimer: this blog contains advertisement and affiliate links to sustain itself. If you click on an affiliate link, I'll be very happy because I'll earn a small commission on your purchase. You can find my boring full disclosure here.