private void Start() { // Disable mesh renderers for head + hands of netObject for local player to prevent overlap with localPlayer. if (isLocalPlayer) { _netHeadObj.transform.Find("SortingHat").GetComponent <MeshRenderer>().enabled = false; _netLeftCtrl.transform.Find("vr_glove_left_model_slim").transform.Find("slim_l").transform.Find("vr_glove_right_slim").GetComponent <SkinnedMeshRenderer>().enabled = false; _netRightCtrl.transform.Find("vr_wand").transform.Find("slim_r").transform.Find("vr_glove_right_slim").GetComponent <SkinnedMeshRenderer>().enabled = false; _netRightCtrl.transform.Find("vr_wand").transform.Find("Wand4").gameObject.SetActive(false); } // Get ExperimentManager. if (_expManager == null) { _expManager = GameObject.FindGameObjectWithTag("ExperimentManager").GetComponent <NetExperimentManager>(); } }
public override void OnServerAddPlayer(NetworkConnection conn) { // Spawn NetParticipant when client is joining the server (isReady is set to true). Vector3 position = numPlayers == 0 ? new Vector3(-1.5f, 0, -5) : new Vector3(1.5f, 0, -5); GameObject participant = Instantiate(playerPrefab, position, Quaternion.identity); NetworkServer.AddPlayerForConnection(conn, participant); // Spawn UI and tell ExperimentManager that spawning is done. if (numPlayers == 2) { _ipField.SetActive(false); _instructionsLeft = Instantiate(spawnPrefabs.Find(prefab => prefab.name == "InstructionsUILeft")); NetworkServer.Spawn(_instructionsLeft); _instructionsRight = Instantiate(spawnPrefabs.Find(prefab => prefab.name == "InstructionsUIRight")); NetworkServer.Spawn(_instructionsRight); _expManager = GameObject.FindGameObjectWithTag("ExperimentManager").GetComponent <NetExperimentManager>(); _expManager.RpcSpawningDone(); } }