// Use this for initialization public void Start() { //base.OnStartClient(); // don't use OnClientStart - this will cause isLocalPlayer to always return false NetworkIdentity netID = GetComponent <NetworkIdentity>(); if (netID.connectionToClient != null) { networkAddress = "local"; networkID = netID.netId.Value; } else if (netID.connectionToServer != null) { networkAddress = "local"; networkID = netID.netId.Value; } else { networkAddress = "remote"; networkID = netID.netId.Value; } // Cleanup address if client (prepended with :fff::) string[] splitAddr = networkAddress.Split(':'); networkAddress = splitAddr[splitAddr.Length - 1]; // Set gameobject name if (networkID > 0) { gameObject.name = "VRNetworkPlayer(" + networkAddress + " " + networkID + ")"; } localPlayer = isLocalPlayer; // Create the UI label GameObject playerLabelObj = Instantiate(characterLabelPrefab, transform.position, transform.rotation) as GameObject; playerLabelObj.transform.parent = transform; playerLabelObj.transform.localPosition = Vector3.up * 2f; playerLabel = playerLabelObj.GetComponent <CharacterLabelUI>(); if (!localPlayer) { // Disable non-local player cameras Camera[] playerCamera = gameObject.GetComponentsInChildren <Camera>(); foreach (Camera c in playerCamera) { c.gameObject.SetActive(false); } headMarker = Instantiate(headMarkerPrefab); headMarker.transform.parent = transform; wandMarkers[0] = Instantiate(wandMarkerPrefab); wandMarkers[0].transform.parent = transform; // CAVE2 - Tell Lobby Manager player needs to be spawned on display nodes if (CAVE2.IsMaster()) { GameObject lobbyManagerObj = GameObject.Find("NetworkManager"); if (lobbyManagerObj && networkID > 0) { CAVE2VRLobbyManager lobbyManager = lobbyManagerObj.GetComponent <CAVE2VRLobbyManager>(); lobbyManager.SpawnPlayerOnCAVE2(gameObject); } } } else { if (CAVE2VRLobbyManager.LobbyManager.cave2Client) { headMarker = Instantiate(headMarkerPrefab); headMarker.transform.parent = transform; wandMarkers[0] = Instantiate(wandMarkerPrefab); wandMarkers[0].transform.parent = transform; } playerName = CAVE2VRLobbyManager.LobbyManager.playerName; localPlayerController = Instantiate(localPlayerControllerPrefab, transform.position, transform.rotation) as GameObject; VRPlayerWrapper vrPlayer = localPlayerController.GetComponent <VRPlayerWrapper>(); playerType = vrPlayer.GetVRTypeLabel(); headObject = vrPlayer.GetHead(); wandObjects = vrPlayer.GetWands(); CmdUpdatePlayerLabel(playerName, playerType); } UpdatePosition(); }