using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public Camera standByCamera;
SpawnSpot[] spawnSpots;
void Start(){
spawnSpots = GameObject.FindObjectsOfType<SpawnSpot>();
Connect();
}
void Connect(){
PhotonNetwork.ConnectUsingSettings("Distructor 1.0");
}
void OnGUI(){
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
void OnJoinedLobby(){
Debug.Log ("OnJoinedLobby");
PhotonNetwork.JoinRandomRoom();
}
void OnPhotonRandomJoinFailed(){
Debug.Log ("OnPhotonRandomJoinFailed");
PhotonNetwork.CreateRoom (null);
}
void OnJoinedRoom(){
Debug.Log ("OnJoinedRoom");
SpawnMyPlayer();
}
void SpawnMyPlayer(){
if(spawnSpots == null){
Debug.LogError ("WTF?!");
return;
}
SpawnSpot mySpawnSpot = spawnSpots[Random.Range (0, spawnSpots.Length)];
GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
standByCamera.enabled = false;
((MonoBehaviour)myPlayerGO.GetComponent ("FPSInputController")).enabled = true;
((MonoBehaviour)myPlayerGO.GetComponent ("MouseLook")).enabled = true;
myPlayerGO.transform.FindChild ("Main Camera").gameObject.SetActive (true);
}
}
In the Unity the camera on the child of CharacterController is disabled.
So this code:
myPlayerGO.transform.FindChild ("Main Camera").gameObject.SetActive (true);
Must work!!! But didn’t work!