Search Unity

Unity Oculus Rift Multiplayer

Discussion in 'AR/VR (XR) Discussion' started by AlexLiquona, Jul 16, 2018.

  1. AlexLiquona

    AlexLiquona

    Joined:
    Dec 6, 2016
    Posts:
    12
    Hello,
    I'm having some real trouble trying to create a two person (or more) VR experience with the Oculus Rift and Unity.
    I'm using the OVRCameraRig together with VRIK, which works really nicely so far as a one player, it's good fun messing around in front of your reflection.

    But I'm having real trouble adding a second person correctly. I'm using the Unity network manager to host/client my game and spawn players - this works! Though with each spawn I'm seeing the instance replicate the tracking movements of the local player. On the host, you can see your own body (instance), when the client joins you can see their instance, but it has your tracking movement from their position. And it's the same case on the client - they can see their local body/movement which is replicated on to the other instance. I hope that's understandable.

    I imagine that I would need to disable the OVR Tracking on each of the other instances, this works when I disable manually in the Unity player, but being that they all work off the same spawn player prefab I can't get my head around how to disable individually.

    I have a script on the prefab [-- if (isLocalPlayer) { Destroy(this); --] To try and run a script to disable OVR tracking, it works for the host machine - the host is tracking, the client instance is still. I think I'm nearly there - but then it has then also disabled all tracking on the client machine.

    Has anyone managed what I'm trying to do - I've been searching for days. So I'm now asking.
    Once I've cracked the above I'll then be using Network Transform to send tracking positions to and from each of the instances/clients.

    I hope someone has an idea, or better way to do this. Many thanks!
    I'm using Unity 2017.3.1
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,532
    With any multiplayer application it comes down to what information you need to send to the other clients. In this case you only really need to know the other client's avatar position and rotation information. It's not VR specific and can be sorted out by applying basic networking principles.

    I would suggest looking around for some basic networking tutorials and understanding more about how to structure your systems to accommodate what you're trying to do. The Learn section of the site is probably a good place to start.
     
  3. AlexLiquona

    AlexLiquona

    Joined:
    Dec 6, 2016
    Posts:
    12
    Thanks LaneFox for taking the time to respond.
    Step one was indeed using a tutorial to create a simple scene, a cube player prefab that moves, another joins the game as a client, both cubes could then be moved in a multiplayer environment. Hardly a 'Call of Duty' deathmatch, but it worked. ;)

    The extra VR level, I would have thought would have been a straight forward elevation of this code, but has proved very tricky trying to keep the VR tracking to the local player only.