Motion Controllers (Vive or Oculus) without plug-ins (SteamVR or Oculus Tools)

Is it possible to make use of the motion controllers (Vive) or the Oculus Touch controllers with native Unity 5.5 - i.e. without the SteamVR asset nor the Oculus Tools?

I noticed that the Vive HMD works fine without SteamVR, but I’m not sure how and where to add controller support, as they don’t “simply work”.

Any pointers would be greatly appreciated.

Figured it out. For anyone else looking, create a custom script for your controllers and set their position yourself which you get using the methods in https://docs.unity3d.com/ScriptReference/VR.InputTracking.html

We also support the axis/button inputs via the normal input manager. The documentation has more details:

1 Like

Hi Nick,

thanks for the answer!

I implemented input yesterday, though it took me quite some time to figure it out. The precise steps could be more explicit in the docs I think. I got a working implementation, but I am not sure this is the right way - so, can you confirm that the best way to map the buttons is to…:

  • for (just pressable) buttons, create an “key or mouse button” axis in the input manager, and then use “joystick button ” as the positive button in the axis, where buttonNr comes from the page you linked (“Unity Button ID”)

  • for 0-1 buttons like the trigger and for the thumbsticks/touchpad, create an “Joystick Axis” axis in the input manager, and then set the axis to , where axisNr comes from the page you linked (“Unity Axis ID”)

…?

Since I am currently trying to completely support both Vive and Oculus with native Unity, some follow-up questions for you:

  • How do I trigger haptic feedback on the controllers?
  • How can I get the velocity of the controllers, which is required for throwing things (at least in the SteamVR plugin they use that to throw, maybe there is another way)
  • The axis of the trigger is only 0 or 1 for me - no intermediate values.
  • While loading scenes, at least SteamVR with the Vive drops back into the “This is real” compositor. The SteamVR plugin offers a way to set a custom loading screen. Is this possible in stock Unity?

Thanks!

@plmx ,

The way you set up button and axis input is correct, sorry it was such a pain!

As for your other questions:

  • Haptic feedback is not supported natively, yet.
  • In our public releases, querying velocity of the controllers is not native but is coming very very soon.
  • Hmmmm, axis of the triggers should return intermediate values… Perhaps check that you’re not casting the value to an int. If that’s not the case, try playing around with the Gravity, Dead, and Sensitivity properties on the associated input element in the Input Manager.
  • I’m not sure! I’ll ask around.

-Will

Unity QA

1 Like

From developer Ed:

“Currently that isn’t possible, but it is possible to do through either the Oculus or SteamVR Utilities. I believe they would just have to set the compositor [through the Oculus or SteamVR utility] until Scene.isLoaded (Unity - Scripting API: SceneManagement.Scene.isLoaded) is true and then Reset the compositor”

-Will

1 Like

@williamj Thanks very much for your detailed answers, very much appreciated!! It seems like you want to include all of the functionality I mentioned in Unity itself at some point, which is great!

Do you already have a version planned for the haptics, which in addition to the velocity, would be the most important for me?

Regarding the axis: It’s a float, but setting the sensitivity to 1 did the trick. Thanks!

@williamj @NickAtUnity One more thing here is the size of the play area for room-scale mode. Is there a way to get that in stock Unity? Planned?

For both haptics and play area, we are currently looking at how best to expose that via native Unity APIs. We have no timeline in place, but are doing the R&D to figure out how we can give developers access to those systems in a way that will work smoothly and consistently with various SDKs.

1 Like

Thanks!

sorry to revive this thread, but it looks like you have a good handle on with what I’m dealing with now…

I’m trying to map the Touch buttons in the Input Manager, and I’m having some issues reading all of the buttons. I followed what plmx suggested, but here are the mappings I’m getting:

Button.One is “A” which is “joystick button 0” in the chart

  • “joystick button 0” actually fires when I press “B”

Button.Two is “B”, but the Unity Button ID isn’t in the chart

Button.Three is “X” which is “joystick button 2” in the chart

  • “joystick button 2” actually fires when I press “Y”

Button.Four is “Y” but the Unity Button ID isn’t in the chart

Button.PrimaryThumbstick and Button.SecondaryThumbstick work as expected (8/9)

So with this setup I can read B and Y but not A and X… Super confusing, am I missing something stupid here? thanks!! I’m on Unity 5.5 with Rift/Touch, OpenVR/SteamVR Plugin

1 Like

I am working on implementing the Vive controller buttons now using just Unity native input. Most is OK but I am not happy with the trigger button. The button ID 14 (left) and 15 (right) goes true before the click in the Vive controller. The float value from the corresponding axis 9 (left) and 10 (right) is 0.25 when the value goes true and 0.2 when it goes false. The float value goes all the way up to 0.9 before the click is heard. When the click happens the float value jumps to 1.0. I can use a check to see if the value is 1.0 for the actual click but but it would be nicer if the Unity implementation actually used the button click for bool value of button ID 14 and 15 in stead of the 0.2-0.25 hysteresis implementation…

This thread was super helpful!

Also, is there a clever way to detect when controllers are active/inactive? Like, when they’re tracking vs when they are not? I’m trying to switch to full native and I can’t seem to find that one. (I’m on 5.6.0f3)

EDIT:
Looks like in 2017.1b there’s VRNodeState.tracked which contains the goods. Guess I gotta go beta for it.

sorry to necro this thread but i seem to be running into similar problems using unity 5.6 trying to dispose of steam VR and hook in my own implementation. cant seem to get the touch buttons to work on on any of the controls and as bzor mentioned the mapping is incorrect for the documentation

1 Like

We gave up on native Unity VR support and are now using SteamVR and OculusTools. There are just too many things that do not work or do not work correctly for implementing it natively. Real deal-breakers are (in 5.6):

Some more minor things which are still annoying:

Unless Unity addresses these, we are sticking to the plug-ins (and a custom-made wrapper).

Sorry I can’t be of more help here.

2 Likes

A true cross platform API for VR with Unity is still a ways off. If you take a look at the 2017 betas you will see that VR.InputTracking does have quite a few additions but still not comprehensive. In general, Unity has stated that they are looking to get things fairly universal around the time of their new input system which is still very experimental and will only result in another experimental build later this summer. Realistically speaking I think we can count on at least another year of using the utilities from each vendor.

Hi! Is there any update on the haptic feedback using the Unity VR API?

It’s not in the beta yet so doesn’t look like anytime soon.

https://docs.unity3d.com/2017.1/Documentation/ScriptReference/VR.InputTracking.html

Thanks Gregg! Guess I ll keep waiting then

Can someone please update the https://docs.unity3d.com/Manual/OpenVRControllers.html page to make this more clear? Because i had the same “problem” the page does no where mention that you have to enter “joystick button ” i thought i only have to enter the number and it took me a while to find a answer