This Code Does Not Spawn A Player Why?

using UnityEngine;
using System.Collections;

public class NetworkManager : MonoBehaviour {

public Camera standbyCamera;
SpawnSpot[] spawnSpots;

// Use this for initialization
void Start () {
	spawnSpots = GameObject.FindObjectsOfType<SpawnSpot>();
	Connect ();


// Update is called once per frame
void Connect () {

	PhotonNetwork.ConnectUsingSettings ("V1");


void OnGUI () {

	GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());

void OnJoinedLobby (){

	PhotonNetwork.JoinRandomRoom ();

void OnPhotonRandomJoinFailed (){
	PhotonNetwork.CreateRoom (null);

void OnJoinedRoom (){

	SpawnMyPlayer ();

void SpawnMyPlayer (){
	if (spawnSpots == null) {
	SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0,spawnSpots.Length)];
	PhotonNetwork.Instantiate ("PlayerController",mySpawnSpot.transform.position,mySpawnSpot.transform.rotation,1);
	standbyCamera.enabled = false;


Hi there

  1. I tried to follow the link you gave but got Access Denied by the forum (?) so I’m answering here.

  2. I think the problem with the Instantiate(…) call is the issue. What will be instantiated? see below…

Normally with Instantiate() calls you need either an existing GameObject to clone or a Prefab but a string (object name?) is almost never supported. It’s possible you don’t get a compile error because an overload is expecting to get an hierarchy path to an object to clone.

A simpler and often better way is to make a public GameObject field in your class and then set that to the prefab or Scene object using the Inspector Window.

If you are now getting a NullReferenceException this could explain it… but I make no guarantees - I haven’t tried the Photon API.