Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Support for both: Vive and Oculus

Discussion in 'AR/VR (XR) Discussion' started by creat327, May 24, 2016.

  1. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Hi

    Is there a way to add support for both on the same game? The plugins and scripts seems incompatible so you can't have one game supporting both VR systems, or so that seems.

    Anyone managed to achieve it? what's the trick?
     
  2. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    SteamVR appears to support that, from here:

    My game only works with a game pad and Oculus headset. Is it hard to make it work on the Vive too?
    It is pretty simple to get your game working on the Vive on Steam. You will want to download the OpenVR SDK and target this for one of your launch options on Steam. It is great if you can make use of the Vive controllers and room-scale in your title, however it is not required to support the Vive and SteamVR.

    You can still require a Xinput controller and even target the Rift and Vive simultaneously using OpenVR on Steam. Steam VR supports both the Rift and Vive headsets along with sitting, standing and room-scale experiences using a mixture of input devices. SteamVR is a flexible place for VR!
     
  3. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    That's in theory. In reality when I plug the oculus with the openVR I don't get it to work. I have to set it to OculusSDK but then the Opensdk stops working
     
    BadSeedProductions likes this.
  4. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    In Unity 5.4 you get a list of Unity Native VR API's so you can setup support for multiple ones and have some control.

    I would assume that alternative methods other than native unity ones, and add-ons that go beyond the basic functionality provided by native support, are more likely to clash, especially at this stage of the game. I only have oculus DK2 hardware so I can't really test this stuff out but if it were me I'd probably try a 5.4 beta and not install any additional Unity VR assets, and see if you can get both working in this barebones manner first.
     
  5. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    you can't. I guess nobody has done it yet from the answers I read.
    The only way I see it is to detect at runtime the returned values on the VR names and load certain prefabs or another.
     
  6. xhonzi

    xhonzi

    Joined:
    Apr 2, 2013
    Posts:
    205
    I would say an even better question is this- what can I do today to ensure (or at least- make more likely) compatibility with tomorrow's VR head and handsets?
     
    ROBYER1 likes this.
  7. GoesTo11

    GoesTo11

    Joined:
    Jul 22, 2014
    Posts:
    604
    I did a quick test on my project with 5.4.0b18. If the Vive is the first SDK listed, the rift runs through OpenVR and works fine. If the Oculus SDK is the first listed, the rift runs through the Oculus SDK. If you are using the SteamVR camera prefab, the tracking when using the Oculus SDK is over sensitive but if you use a regular Unity camera, it works fine. The Vive seams to work no matter how you set it up.

    I guess that the best solution to get the two to play nicely is to have the Oculus SDK listed first and have separate camera setups depending on whether a rift or vive is connected. You could just use OpenVR for the rift but then you would miss out on ATW.
     
  8. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    yeah, that's what I'm doing: load different stuff depending on what VR is detected.
    But I was hoping Unity was able to save me from VR nightmare. Because I also have to consider now Google Cardboard and Samsung Gear VR. It seems I have to create different assets for every single one of them.

    Also in the case of Android, if you enable support for VR and your phone doesn't have the Gear connected, instead of loading normally without VR on, it will crash immediately. Very messy right now.
     
  9. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    Is it not because of the Manifest.xml ? I have yet to try, but i guess it could work by overriding it.
    Edit : Why would you let VR support enabled for regular android app ? I would go with multiple apk.
     
    Last edited: May 27, 2016
  10. BadSeedProductions

    BadSeedProductions

    Joined:
    Dec 26, 2014
    Posts:
    144
    I have been working on a Rift/Vive application. I used the OVR camera rig and Steam picks it up fine after adding OpenVR, but now after adding open VR the application crashes when opening on the Rift. (tries to open it through SteamVR instead of using Oculus' launcher)
     
  11. bo3b

    bo3b

    Joined:
    Nov 28, 2016
    Posts:
    2
    It looks to me like the SteamVR Camera Prefab causes the problem of overly sensitive (2x) tracking.

    I think this happens because the Prefab has two Cameras in it, one for the Head, and one for the Eye. Which calls the Oculus SDK twice for headtracking, making it double up.

    This seems like a bug or conflict between the Unity Oculus SDK use, and the SteamVR plugin Camera Prefab.
     
  12. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    I was going to say just build separate apps for the Oculus Store and Steam but it occurred to me that Steam users have Rift HMD's too. So is it better to have the OVR SDK as first choice and Oculus SDK as second choice or vice versa? What is the code to find out what HMD they are running?
     
  13. bo3b

    bo3b

    Joined:
    Nov 28, 2016
    Posts:
    2
    My goal is to have a single app that works on both Rift and Vive. It's always possible to do separate apps, but a big part of using a tool like Unity is to make this easier so that we don't have to.

    Using the SteamVR plugin for Unity, from the Asset-Store, you get access to the OpenVR SDK, and the CameraRig Prefab.

    I used the CameraRig as a simplifying factor, exactly what I'm looking for in terms of the tools handling abstraction for me.


    However... once I use that CameraRig, I get the problem of the doubled up headtracking. Not certain, but I read in a different forum that a user had a similar problem from two cameras. Presumably that should be handled here, but I think it is not.

    Because, if I remove the OculusSDK from the list of supported Virtual Reality SDKs (in Settings->Player), and leave only the OpenVR SDK, then the double headtracking is resolved. Importantly, this also still works upon both Rift and Vive. At runtime, it launches SteamVR, which then launches Oculus Home. It mostly does what I want, with the caveat being that I really have no idea what I'm doing, I'm no expert.

    The downside is that I no longer have access to the Oculus Remote Control. That seems to only be supported via the Oculus SDK. I can still access the Xbox controller in both.


    If you want to use both, you must have the Oculus one first, otherwise it will launch SteamVR. Or use it if you want your Rift users to not be required to launch SteamVR.

    If you want to include both SDKs, the way to determine which one is loaded is:

    Code (csharp):
    1. if (UnityEngine.VR.VRSettings.loadedDeviceName == "OpenVR")
    2. {
    3. }
    That is the current recommended approach. There was a enum technique which has been deprecated.
     
    midnightcrawler1 likes this.
  14. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    Thanks for that info. Becoming an expert in Unity means knowing the workarounds and you are on yer way:) I just sent my Cyclotronica VR game to the Oculus Store last night an am waiting for it to go live. I am going to tackle the Steam Store next so i will jut replace the Oculus SDK with the Open VR one for that store. it won't be that much of a hassle to mke a specifric build for Steam with just a camera change. i already have the ability to toggle between VR and standard desktop using the V key or B button on the controller. I did not bother with using the Oculus remote. Seems to e it should be using the virtual axis anyways so..and I am assuming everyone with a Rift HMD has an XBox controller... fingers crossed..
     
  15. bo3bber

    bo3bber

    Joined:
    May 27, 2013
    Posts:
    4
    As an update here:

    I disabled the second camera in the CameraRig prefab, by unchecking the box when CameraHead was selected.

    This fixes the double head-tracking problem on Rift as was suspected. This also allowed me to keep both Oculus and OpenVR SDKs in my project, so I could make a single build that worked on both, with full support for Oculus Remote, Vive Controllers, Xbox controller, and keyboard and mouse.

    I had expected that to disable the mirror copy to the monitor, but that still works. So... I don't know if there is any negative side-effect, but it looked good in my testing.
     
  16. daterre

    daterre

    Joined:
    Jul 30, 2012
    Posts:
    41
    FYI:
    I had trouble getting the Oculus controllers to work in a scene with the SteamVR camera rig. The camera was working fine, but OVRInput.GetConnectedControllers() was returning None. After a little digging around, this is what solved it for me:
    • Make sure both Oculus and OpenVR SDKs are listed under Player settings > Virtual Reality SDKs
    • Call OVRInput.Update() and OVRInput.FixedUpdate() from a customs script. (This is normally called from OVRManager on the OVRCameraRig, which isn't present in the scene when using SteamVR's setup)
    Hope that helps.
     
  17. Dreamwriter

    Dreamwriter

    Joined:
    Jul 22, 2011
    Posts:
    472
    Note that as far as I know, Oculus won't accept a game into the Oculus Home store if that game supports any other headsets. They check for the presence of the OpenVR SDK and reject any game that includes it.
     
  18. Khyrid

    Khyrid

    Joined:
    Oct 8, 2010
    Posts:
    1,790
    That's terrible. They better not.
     
  19. Abnormalia_

    Abnormalia_

    Joined:
    Jul 23, 2013
    Posts:
    128
    We wanted to have Native projects but not 2 separate project, so I've made small program:



    Now we can have native Oculus and HTC project. Share same prefabs (which are different for each) and same scenes and assets. Needs just one click before submitting to repo or after to apply SDK and setting to project.

    What are other solutions for that ?
     
  20. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    I guess what he means is that Oculus rejects builds which include the openvr DLL. This is the error message you get when submitting:

    Code (csharp):
    1.  
    2. "The package contains DLL libraries that are known to cause issues when
    3. running on the Oculus platform. These files must be removed prior to
    4. uploading: <path>/Plugins/openvr_api.dll"
    5.  
    So, to submit to the Oculus store you'll have to remove any OpenVR-based elements (basically create an Oculus-specific build).
     
  21. Abnormalia_

    Abnormalia_

    Joined:
    Jul 23, 2013
    Posts:
    128
    Make small script to ease process:

     
  22. TheWarper

    TheWarper

    Joined:
    Nov 3, 2013
    Posts:
    112
    Is that true?
     
  23. Beep2Bleep

    Beep2Bleep

    Joined:
    Sep 12, 2012
    Posts:
    8
    Yes, I tested this last week, if you have the OpenVR SDK files it will fail. You can submit a build that has the OpenVR SDK in Unity, but if you have any of the SteamVR tracking/camera rigs (not that it would work) it will reject it still. If your app works with Oculus then removing the .dlls isn't a big deal since you can just make a build, then delete the.dll files before zipping and uploading at it will be accepted.
     
    glenneroo, TheWarper and Gruguir like this.
  24. Gruguir

    Gruguir

    Joined:
    Nov 30, 2010
    Posts:
    340
    It's to note that on the contrary you can publish an Oculus native game on Steam.

    There are some elements of a project that require third party sdk if you want to publish it on the Oculus store for instance, but it's tied to publishing / social APIs features (only if you use them).

    i would advice for a single, cross-platform, work project, once comfortable with VR dev and bored of proprietary APIs locks, to plan it in an hardware agnostic way, using Unity's native XR class. You can then at a later stage implement respective APIs for publishing and specific features.
     
    scvnathan likes this.
  25. Jamy4000_Absolute

    Jamy4000_Absolute

    Joined:
    Oct 18, 2017
    Posts:
    5
    Hey everyone,

    Thanks for your advice on this threads, it helped me a lot to understand how a cross-platform app could look like !

    If some people are still interested in the subject, i created a VR Framework based on the Scriptable Objects (You can find more info about those online, but I really think this video and the demo project linked to it is the best to understand them). This repo use Scriptable Variables, Scriptable GameEvents, ...

    I'm not sure this would be the best approach, but It's working nicely right now. I created a repo containing some basic features and support for OpenVR, Oculus and a VRSimulator (this last one is still in Beta). If anyone is interested, it's here !

    I also started to work on the Wiki of the Repo, and the basics stuffs to set everything up are inside of it. I will update it in the next couple of weeks normally !

    Hope it will help someone :)
     
    Last edited: Mar 21, 2018
  26. midnightcrawler1

    midnightcrawler1

    Joined:
    Jan 17, 2017
    Posts:
    15
    Right on point! Moving Oculus SDK to the top solved the problem of always loading SteamVR.