Search Unity

VR and Non-VR in a two player game?

Discussion in 'AR/VR (XR) Discussion' started by dinozombie, Nov 13, 2016.

  1. dinozombie

    dinozombie

    Joined:
    Nov 13, 2016
    Posts:
    2
    Hello, I have very little experience in making games with unity. I was planning on making a simple two player game with one player on the keyboard and the other on the DK2. The first problem I ran into is the cameras. When I click run, the GAME tab only shows one camera. The second issue I encountered was with the DK2.
    When I used unity's vr controller asset (Has worked for me before), and clicked build and run, unity launches the game, but it doesn't get sent to the DK2. Any information you could provide me would be useful. Thanks!

    Current Versions: DK2 runtime: 0.7
    Unity 5.4.1
    Things I've tried: Placing 2 Cameras in Scene
    Changing the Display # on the GAME tab
     
  2. NickAtUnity

    NickAtUnity

    Unity Technologies

    Joined:
    Sep 13, 2016
    Posts:
    84
    Make sure you go to the Player Settings and enable VR and ensure the Oculus SDK is added to the list. That is required for the engine to enable VR.

    As for having one player not in VR, you can configure cameras to be specific to the HMD or main display. Look at the Target Eye property in the Inspector. You can set it to "None" which makes that camera render only to the main display. This way you can vary what renders for each player.
     
  3. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Hi @NickAtUnity . This thread is the closest I can find to my question and since a Unity tech is on it I an hopefully get a swift answer. I want my game to be optional VR. It needs two separate UI World Space cameras to make thew UI correct for the 16:9 standard build but the camera for the VR UI needs shifting back about 100 units. Second, when I build I want to test in standard mode and do a video of gameplay for the Oculus Store asset list but it always opens up the Oculus app. How do I make it so that when you start the game you can choose to run it in standard mode or VR..even if you have an HMD hooked up already?
     
  4. NickAtUnity

    NickAtUnity

    Unity Technologies

    Joined:
    Sep 13, 2016
    Posts:
    84
    If VR is enabled in the player settings, the engine will initialize the VR system on startup. The reason is that many games are launched from inside VR headsets (either through Oculus or other) and in those environments you need to start rendering to VR right away without a non-VR desktop display window.

    You might look into making an in-game UI that supports both VR and non-VR inputs to prompt whether or not the user wants to continue in VR. You can query and modify VRSettings.enabled to control it.
     
  5. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    I queried for a HMD and if found I gave the option to hit the V key or B button to toggle in and out of VR mode. For the UI I was simply able to change the UICamera FOV for the standard UI to get it to fit and was able to keep the camera for VR as it was.
     
  6. NickAtUnity

    NickAtUnity

    Unity Technologies

    Joined:
    Sep 13, 2016
    Posts:
    84
    Sounds like you got it sorted out. I did want to also mention we have a couple other APIs for checking for VR devices:

    VRDevice.isPresent: This API should tell you whether or not a VR device is present and ready to use.
    VRSettings.isDeviceActive: This API should tell you whether or not Unity is actively using VR device.

    The enabled property I mentioned above is more for specifying whether or not your game wants to be using VR, whereas these APIs are read-only properties to introspect what the engine itself sees about the state of the VR device.

    Hope all this has been helpful. :)
     
  7. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Yes
    Yes..It was helpful. I have read that if I have my app set up for Oculus CV1 that I can import the HTC Vive SDK and I am good to go with a recompile and doing whatever else Steam wants for the Steam Store?
     
  8. NickAtUnity

    NickAtUnity

    Unity Technologies

    Joined:
    Sep 13, 2016
    Posts:
    84
    Not sure exactly what you're asking, but the Oculus CV1 does work with the SteamVR/OpenVR SDKs. If you're using a version of Unity with the VR SDKs built in, you can simply add it to the list of supported SDKs in the PlayerSettings.
     
  9. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    I am seeing in this thread that they can get funky if you have Oculus and Vive in the same app.
    https://forum.unity3d.com/threads/support-for-both-vive-and-oculus.406222/
    I am using the 5.5.0f1 beta. Is the issues brought up in that thread resolved?
     
  10. NickAtUnity

    NickAtUnity

    Unity Technologies

    Joined:
    Sep 13, 2016
    Posts:
    84
    That thread referenced a non-built in SDK which may have had issues (I wasn't working here at that time). I do know our built in OpenVR SDK in 5.5 works with Oculus DK2 and CV1 hardware as we test on both regularly.

    Possibly worth noting, if you use the built in SDK list, we only ever have one SDK initialized at a time. We iterate the SDKs in that list (in order) and attempt to initialize them, stopping as soon as one initializes and connects to an HMD. So if you put Oculus first, we'll try to use the Oculus SDK first. If that doesn't work (for any reason, such as the user doesn't have Oculus) then we move on to the next SDK in your list.

    Beyond that if you have custom scripts or game objects that are making assumptions about which SDK is being used, it's up to your scripts to handle the different SDKs being used. If you have multiple camera rigs specific to each SDK, for example, your game would want to check which VR device is being used and instantiate the correct one.
     
  11. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    OK. Seems like a good way to travel:) There are these issues from another thread about the B and Y buttons not being able to be used. I happen to use ONLY those buttons.
    https://forum.unity3d.com/threads/port-vive-game-to-oculus.442332/
    Enjoy your stay at Unity. Stay on this forum please as the Oculus forum has a dozen threads with pertinent questions and no answers in their forums.
     
  12. dinozombie

    dinozombie

    Joined:
    Nov 13, 2016
    Posts:
    2
    @NickAtUnity Thank you for the response! I have the VR box checked and Oculus is listed under SDKs, yet my DK2 shows no sign when I hit play. Also, what should the Target Eye be set to on the oculus player? HMD isn't showing as an option.
     
  13. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Try using just a regular camera. It should work out of the box with VR with single pass stereo rendering.
     
  14. franciscochong

    franciscochong

    Joined:
    Jul 9, 2015
    Posts:
    30
    @NickAtUnity Hi
    How exactly does the above works?
    Does this need multiplayer? how do you sync 2 devices? to run the same game one vr and the other non vr? im trying to make this sync possible, tried mirrorop while it does what it advertises, it shows as vr inj the 2nd display, in my test case from a samsung gear to an iphone, but the iphone had the 2 separate eye renders, exactly as what was running on the samsung gear vr, how do you cast it withoujt vr to the other device?