using UnityEngine;
using System.Collections;
public class networkmanager : MonoBehaviour {
public Camera lobbycamera;
SpawnSpot[] spawnSpots;
void Start ()
{
spawnSpots = GameObject.FindObjectsOfType<SpawnSpot> ();
Connect ();
}
void Connect()
{
PhotonNetwork.ConnectUsingSettings ("0.0.1");
}
void OnGUI()
{
GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString());
}
void OnJoinedLobby()
{
PhotonNetwork.JoinRandomRoom ();
}
void OnPhotonRandomJoinFailed()
{
PhotonNetwork.CreateRoom (null);
}
void OnJoinedRoom()
{
SpawnMyPlayer ();
}
void SpawnMyPlayer ()
{
SpawnSpot mySpawnSpot = spawnSpots[ Random.Range (0, spawnSpots.Length) ];
GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
lobbycamera.enabled = false;
((MonoBehaviour)myPlayerGO.GetComponent("FPSInputController")).enabled = true;
((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true;
myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true);
}
}
It would help immensely if you copied the actual error message, and also what you've tried so far.
– guitarxeIt looks like the spawnSpots array is empty, you should Debug.Log out the length of the array and come back to us with that number. It's probably not able to find any objects of type SpawnSpot. Just a guess though.
– stevethorne