- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Amichel252 · Jul 09, 2014 at 01:52 PM ·
error
error CS0103 The name `SpawnSpots' does not exist in the current context
Hi There,
I am working on an F2P FPS game but i get Assets/NetworkManager.cs(40,20): error CS0103: The name `SpawnSpots' does not exist in the current context.
Can you help me how to fix this
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public Camera standbyCamera;
SpawnSpot[] spawnSpot;
// Use this for initialization
void Start () {
spawnSpot = GameObject.FindObjectsOfType<SpawnSpot>();
Connect ();
}
void Connect() {
PhotonNetwork.ConnectUsingSettings ("BlackOut Online 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 = spawnSpot[ Random.Range (0, spawnSpot.Length) ];
PhotonNetwork.Instantiate("First Person Controller", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
standbyCamera.enabled = false;
}
}
Comment
Answer by robertbu · Jul 09, 2014 at 02:10 PM
You declare the variable 'spawnSpot' without the 's' on the end and a upper case 'S', but you use it as 'SpawnSpots' with an 's' on the end and a upper case 'S'. Variable names must match exactly including case.