Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-1
Question by cjones · Nov 05, 2013 at 04:18 AM · error-handling

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;
                     }
                 }
             }
         }
     }
 }
Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Huacanacha · Nov 05, 2013 at 04:31 AM 0
Share

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.

avatar image Huacanacha · Nov 05, 2013 at 05:23 AM 0
Share

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).

avatar image cjones · Nov 05, 2013 at 06:57 AM 0
Share

if you look at the screenshot you can see that it is all assigned

avatar image cjones · Nov 05, 2013 at 06:58 AM 0
Share

here is my hierarchy http://gyazo.com/e31b918e8d0c97365cf069a29c1b62cc.png the playerone and playertwo are set but they are prefabs

avatar image Huacanacha · Nov 05, 2013 at 07:08 AM 0
Share

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).

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges