- Home /
Why am i getting this error?
UnassignedReferenceException: The variable SpawnPointone of 'SpawnManager' has not been assigned. You probably need to assign the SpawnPointone variable of the SpawnManager script in the inspector. SpawnManager.OnGUI () (at Assets/Standard Assets/Scripts/SpawnManager.js:40)
It says its not assigned but it is here's a screenshot http://gyazo.com/143947785a411bd52005fc1ef0fa7b5a.png
Here's my SpawnManager Script
#pragma strict
var Connection : boolean = false;
var Playerone : GameObject;
var Playertwo : GameObject;
var SpawnPoint : String = "";
var Dead : boolean = true;
var SpawnPointone : GameObject;
var SpawnPointtwo : GameObject;
var CenterW : float;
var CenterH : float;
function Start () {
SpawnPoint = "";
CenterW = Screen.width / 2 - 150;
CenterH = Screen.height / 2 - 80;
}
function OnGUI()
{
if(Network.peerType == NetworkPeerType.Disconnected)
{
Connection = false;
}
else
{
Connection = true;
}
if(Connection == true)
{
if(SpawnPoint == "")
{
GUI.Box(Rect(CenterW, CenterH, 300, 160), "Select a Spawnpoint");
if(GUI.Button(Rect(CenterW + 5, CenterH + 20, 290, 65), "Spawn 1"))
{
Network.Instantiate(Playerone, SpawnPointone.transform.position, transform.rotation, 0);
SpawnPoint = "one";
Dead = false;
}
if(GUI.Button(Rect(CenterW + 5, CenterH + 90, 290, 65), "Spawn 2"))
{
Network.Instantiate(Playertwo, SpawnPointtwo.transform.position, transform.rotation, 0);
SpawnPoint = "two";
Dead = false;
}
}
else
{
if(Dead == true)
{
if(GUI.Button(Rect(CenterW + 5, CenterH + 20, 290, 130), "Respawn"))
{
if(SpawnPoint == "one")
{
Network.Instantiate(Playerone, SpawnPointone.transform.position, transform.rotation, 0);
Dead = false;
}
if(SpawnPoint == "two")
{
Network.Instantiate(Playertwo, SpawnPointtwo.transform.position, transform.rotation, 0);
Dead = false;
}
}
}
}
}
}
Your code isn't formatted so it's hard to tell, but it looks like the SpawnPointone variable isn't initialized with a value. You probably need to do this in the Start() function, or give it an initial value when declaring it.
O$$anonymous$$ now I can read it :)
Are you assigning a value to SpawnPointone via the Inspector? If not it will have no value as nothing is assigned to it in your code.
Also, you seem to only need to store a Vector3 for position for each spawn point rather than a GameObject (unless you have GameObjects for each Spawn point, in which case you could still just use a Transform).
if you look at the screenshot you can see that it is all assigned
here is my hierarchy http://gyazo.com/e31b918e8d0c97365cf069a29c1b62cc.png the playerone and playertwo are set but they are prefabs
Try changing the variable type to a Transform and re-assigning the GameObject in the Inspector. You can then also add a Debug.Log for the transform in Start() to check what value it contains (if anything).
Answer by cjones · Nov 05, 2013 at 02:25 PM
fully fixed i had added a script to the main camera rofl thanks for all the help. thanks for everything.
Your answer

Follow this Question
Related Questions
Error, I have no idea why :( 2 Answers
Expression denotes a `method group', where a `variable', `value' or `type' was expected 1 Answer
InvalidCastException: Cannot cast from source type to destination type. 1 Answer
melee script help 1 Answer
Double Clicking Errors/Output In The Console Triggered By External Assemblies 0 Answers