- Home /
Duplicate Question
error CS0246: The type or namespace name `SpawnSpot' could not be found. Are you missing a using directive or an assembly reference
Hi,
I am new to unity3d networking and i am trying to create multiplayer fps and i am stucked in an error which says type or namespace 'Game Object' could not be found.
Here is the code of my script
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public Camera standbyCamera;
public SpawnSpot[] spawnSpot;
// Use this for initialization
void Start () {
spawnSpot = GameObject.FindObjectsOfType<SpawnSpot>();
Connect ();
}
void Connect(){
PhotonNetwork.ConnectUsingSettings ("MultiFPS v1.0.0");
}
void OnGUI(){
GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString());
}
void OnJoinedLobby(){
Debug.Log ("joined lobby");
PhotonNetwork.JoinRandomRoom ();
}
void OnPhotonRandomJoinFailed(){
Debug.Log ("OnPhotonRandomJoinFailed");
PhotonNetwork.CreateRoom (null);
}
void OnJoinedRoom(){
Debug.Log ("OnJoinedRoom");
SpawnMyPlayer ();
}
void SpawnMyPlayer(){
if (spawnSpot == null) {
Debug.Log("No spawn spots");
return;
}
spawnSpot mySpawnSpot = spawnSpot [Random.Range (0, spawnSpot.Length)];
PhotonNetwork.Instantiate ("First Person Controller",mySpawnSpot.transform.position,mySpawnSpot.transform.rotation,0);
standbyCamera.enabled = false;
}
}
I would suggest using Google. http://answers.unity3d.com/questions/304724/error-cs0246-missing-type-or-namespace.html
i have gone through that question but it has the problem of constructor na$$anonymous$$g convention and in my case i am not using constructor.
The problem is something else i guess
spawnSpot mySpawnSpot = spawnSpot
the first spawnspot should be capital S like SpawnSpot, just like
public SpawnSpot[] spawnSpot;
Also the answer that Sara posted points out 3 different problems, not just constructors... the problem you have is described similar here: "Your classes are named VigorScr and SkillScr but you are trying to use type Vigor and Skill" where you're trying to use spawnSpot as a class name when the class is actually named SpawnSpot
I have tried SpawnSpot ins$$anonymous$$d of spawnSpot but it gives the same error.
It shows the error on the second line itself while initializing the SpawnSpot array i.e.
public class Network$$anonymous$$anager : $$anonymous$$onoBehaviour {
public Camera standbyCamera;
SpawnSpot[] spawnSpot;<---- the error is shown in this line
// Use this for initialization
void Start () {
spawn = GameObject.FindObjectsOfType<SpawnSpot>();
Connect ();
}
-------
-------
-------
-------
}
Follow this Question
Related Questions
Error CS0246 of plugins everytime the project is opened for the first time. 2 Answers
Instantiating Rigidbodies on PhotonNetwork? Am I doing it wrong? 1 Answer
[error] Getting errors from Photon Networking when creating standalone! 0 Answers
Using JS class in C# 1 Answer
Missing assembly references when importing/upgrading DOTS stack 1 Answer