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

when second player connects the camera rotates randomly

Discussion in 'Multiplayer' started by Keskiner, Mar 23, 2017.

  1. Keskiner

    Keskiner

    Joined:
    Feb 23, 2017
    Posts:
    5
    Hello everyone,

    I'm working on Multiuser Virtual Reality in Unity with using Unity Network Manager and gvr module.

    My problem is:

    When i run the game in android with only 1 player (host), everthing is fine. I can control the VR. However, when second player joins the room, i cannot control VR and The camera is rotating around the player randomly. However, when i exported for the PC and connect multiple users on PC there is not any problem at all.

    Also i have a prefab which includes model and GvrMain on the top of it.
     
  2. Keskiner

    Keskiner

    Joined:
    Feb 23, 2017
    Posts:
    5
    Can anybody help me?
     
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    You need to post some code related to the camera so we can diagnose it and not create duplicate posts in other forum sections.
     
  4. Keskiner

    Keskiner

    Joined:
    Feb 23, 2017
    Posts:
    5
    I'm newbie in forum so im sorry about duplicating.

    Anyway, i'm using the below code for camera. myCam and myAudioListener variables attached in my character prefab.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Networking;
    5.  
    6. public class AddGvr : NetworkBehaviour {
    7.      public Camera myCam ;
    8.      public AudioListener myAudioListener;
    9.  
    10.      // Use this for initialization
    11.      void Start () {
    12.              }
    13.  
    14.      // Update is called once per frame
    15.      void Update () {
    16.  
    17.  
    18.          if (isLocalPlayer) {
    19.              if (myCam.enabled == false)
    20.                  myCam.enabled = true;
    21.  
    22.              if (myAudioListener.enabled == false)
    23.                  myAudioListener.enabled = true;
    24.          }
    25.      }
    26. }
     
    Last edited: Mar 25, 2017