我正在观看有关Photon多人游戏的教程,我一步到位。 这个脚本一切正常,但相机仍未激活。 (激活FPSInputController和MouseLook)。
你认为你可以帮助我吗?
以下是代码:
public Camera standbyCamera;
SpawnSpot[] spawnSpots;
// Use this for initialization
void Start () {
spawnSpots = GameObject.FindObjectsOfType<SpawnSpot>();
Connect ();
}
void Connect() {
PhotonNetwork.ConnectUsingSettings( "v001" );
}
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);
}
}