Search Unity

VIVE Multiplayer problem

Discussion in 'AR/VR (XR) Discussion' started by JannickL, Aug 25, 2016.

  1. JannickL

    JannickL

    Joined:
    May 18, 2016
    Posts:
    78
    Hey there,
    i am trying to build a small multiplayer game for the HTC Vive but i got a problem that i don't get solved.
    I'm using a PUN (Photon Unity Network). After joining a room, a playerPrefab gets instantiated.
    The problem is, that when it test it with two players connected and i move my head (camera) the other ones is moving too. The CameraRig and the head got own Photon View and Photon Transform View Components.

    I guess the problem is in the code but i need an idea how to fix this. I know how networking is done, i got no problems builidng a non vr multliplayer game.

    Maybe someone got a solution? The moving code for the hmd seems to automaticly work for all hmds that are connected.

    Maybe something like if(PhotonView.isMine) but where should i insert this? I'm using the Standard SteamVR Plugin.

    Thank you!
     
  2. deraggi

    deraggi

    Joined:
    Apr 29, 2016
    Posts:
    88
    why do you synchronise the transforms of the head? This will result in your camera movement being synchronized.

    What I did is intantiating models as child nodes, syncing their transforms and disable the head model for the current player so only others can see it
     
  3. JannickL

    JannickL

    Joined:
    May 18, 2016
    Posts:
    78
    Thank you, hope i got it right:

    upload_2016-8-25_18-44-54.png

    That's the prefab that's getting instantiatet, it only got the sync transform on the head (it is just a cube) which is a child of the real tracked head (hmd).

    Using this code to instantiate:

    public void OnJoinedRoom()
    {
    GameObject player = PhotonNetwork.Instantiate("[CameraRig]", transform.position, transform.rotation, 0);
    }


    But i still get the same problem, when i turn my head, his ones is moving too
     
  4. deraggi

    deraggi

    Joined:
    Apr 29, 2016
    Posts:
    88
    What are you actually trying to achieve? I assume that you want to spawn 2 camerarigs, one for each player?

    Just spawn a local one for each player and photon.instantiate the head model with transform synchronisation
     
    JannickL likes this.
  5. JannickL

    JannickL

    Joined:
    May 18, 2016
    Posts:
    78
    Code (csharp):
    1. GameObject player = Instantiate(playerPrefab);
    2. player.transform.position = new Vector3(0, 0.5f, 0);
    3. GameObject playerHead = PhotonNetwork.Instantiate("Head", transform.position, transform.rotation, 0);
    4. playerHead.transform.parent = player.transform.getChild(2).transform.parent;
    So this is what you mean?
     
    Last edited: Aug 26, 2016
  6. deraggi

    deraggi

    Joined:
    Apr 29, 2016
    Posts:
    88
    Exactly :) - but set the camera rig - head object as parent
     
  7. JannickL

    JannickL

    Joined:
    May 18, 2016
    Posts:
    78
    I don't have anyone to test it right now. But i will try later when a friend of mine comes back online again.

    Thank you so far i'll report if it has worked!
     
  8. deraggi

    deraggi

    Joined:
    Apr 29, 2016
    Posts:
    88
    I suggest you find a different workflow so you can test by yourself. You can Build another instance and join as second player using the editor.

    What happens to me is that unity crashes as soon as I have 2 instances with VR open. So I spawn a normal camera for the second player
     
  9. JannickL

    JannickL

    Joined:
    May 18, 2016
    Posts:
    78
    That's what i normaly do too but in this case i want to see the behaviour between two CameraRigs, if his head is still moving when mine is. So i'll need to wait :)

    btw are you german? Because it could be "der aggi" like "the aggi". That would be german :D
     
  10. deraggi

    deraggi

    Joined:
    Apr 29, 2016
    Posts:
    88
    Ja, in der Tat ;).

    Lass mich wissen wenn ich dir noch helfen kann - habe das gleiche vor kurzem auch gemacht
     
  11. JannickL

    JannickL

    Joined:
    May 18, 2016
    Posts:
    78
    Okay super, also ich habe gestern noch einen kleinen Testlauf eingelegt, es schien zu funktionieren! Im laufe des Tages baue ich den Multiplayer mal aus um zu sehen ob alles richtig läuft. Falls nicht melde ich mich hier, danke nochmal!
     
  12. JannickL

    JannickL

    Joined:
    May 18, 2016
    Posts:
    78
    Edit: Ich habe das nun ausführlich getestet und finde folgenden Fehler vor:

    Beide Spieler können ohne Probleme joinen, beide Spieler können sich sehen, wenn ich meinen Kopf bewege bewegt sich bei ihm nichts (ursprüngliches Problem also behoben) jetzt bewege ich mich über Teleport oder Touchpad aber bei dem anderen Spieler wird es nicht angezeigt, obwohl der Kopf also ein Qube ja ein child ist und photon view und transform hat wo position und rotation synchronisiert werden. Alleine das er ein child ist muss doch reichen auch wenn der parent kein photon view bzw transform view hat oder?

    Wärst du so freundlich und würdest einen test mit mir machen? Bis jetzt konnte ich immer nur vive zu pc testen, möchte gerne einmal vive zu vive testen.

    Skype/Steam: Jaudatus
     
    Last edited: Aug 26, 2016