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
0
Question by Dissolver84 · Jun 13, 2012 at 11:02 AM · bug-perhaps

Help with BCE0044 and UCE001 error in my script!

I need help in my script which has two compile errors... "Assets/Scripts/OnPlayerConnectDeathmatch.js(24,27): BCE0044: expecting :, found ';'" and "Assets/Scripts/OnPlayerConnectDeathmatch.js(23,47): UCE0001: ';' expected. Insert a semicolon at the end".

This is my code:

 var player1 : Transform;
 var player2 : Transform;
 var player3 : Transform;
 var player4 : Transform;
 var player5 : Transform;
 var player6 : Transform;
 var player7 : Transform;
 var player8 : Transform;
 var spawnpoint1 : GameObject;
 var spawnpoint2 : GameObject;
 var spawnpoint3 : GameObject;
 var spawnpoint4 : GameObject;
 var spawnpoint5 : GameObject;
 var spawnpoint6 : GameObject;
 var spawnpoint7 : GameObject;
 var spawnpoint8 : GameObject;
 
 function OnNetworkLoadedLevel () {
  if (spawnpoint1.CompareTag("Empty")) {
      Network.Instantiate(player1, spawnpoint1.transform, spawnpoint1.rotation);
      spawnpoint1.tag = "Used";
  }
  else (spawnpoint1.CompareTag("Used")) {
      GoToSpawn2 ();
  }
 }
 function GoToSpawn2 () {
  if (spawnpoint2.CompareTag("Empty")) {
      Network.Instantiate(player2, spawnpoint2.transform, spawnpoint2.rotation);
  }
  else (spawnpoint2.CompareTag("Used")) {
      GoToSpawn3 ();
  }
 }
 function GoToSpawn3 () {
  if (spawnpoint3.CompareTag("Empty")) {
      Network.Instantiate(player3, spawnpoint3.transform, spawnpoint3.rotation);
  }
  else (spawnpoint3.CompareTag("Used")) {
      GoToSpawn4 ();
  }
 }
 function GoToSpawn4 () {
  if (spawnpoint4.CompareTag("Empty")) {
      Network.Instantiate(player4, spawnpoint4.transform, spawnpoint4.rotation);
  }
  else (spawnpoint4.CompareTag("Used")) {
      GoToSpawn5 ();
  }
 }
 function GoToSpawn5 () {
  if (spawnpoint5.CompareTag("Empty")) {
      Network.Instantiate(player5, spawnpoint5.transform, spawnpoint5.rotation);
  }
  else (spawnpoint5.CompareTag("Used")) {
      GoToSpawn6 ();
  }
 }
 function GoToSpawn6 () {
  if (spawnpoint6.CompareTag("Empty")) {
      Network.Instantiate(player6, spawnpoint6.transform, spawnpoint6.rotation);
  }
  else (spawnpoint6.CompareTag("Used")) {
      GoToSpawn7 ();
  }
 }
 function GoToSpawn7 () {
  if (spawnpoint7.CompareTag("Empty")) {
      Network.Instantiate(player7, spawnpoint7.transform, spawnpoint7.rotation);
  }
  else (spawnpoint7.CompareTag("Used")) {
      GoToSpawn8 ();
  }
 }
 function GoToSpawn8 () {
  if (spawnpoint8.CompareTag("Empty")) {
      Network.Instantiate(player8, spawnpoint8.transform, spawnpoint8.rotation);
  }
  else (spawnpoint8.CompareTag("Used")) {
      Network.Disconnect();
  }
 }
 }
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by phren · Jun 13, 2012 at 11:19 AM

The problem here is that you're using else statements with conditions. In this case you should be using else if. I would however prescribe a refactoring of the code in this manner:

 var players : Transform[];
 var spawnPoints : Transform[];

 function OnNetworkLoadedLevel(){
     for(var i = 0; i < players.length && i < spawnPoints.length; i++){
         if(spawnPoints[i].CompareTag("Empty")){
             Network.Instantiate(players[i], spawnPoint[i].transform.position, spawnPoint[i].transform.rotation);
             spawnPoint[i].tag = "Used";
         } else if(i == spawnPoints.length-1){
             Network.Disconnect();
         }
     }
 }

By restructuring your code like this you can add new spawn points and remove old ones more easily. Also with less lines of code you're probably going to introduce fewer bugs. :)

Comment
Add comment · Show 2 · 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
avatar image Dissolver84 · Jun 13, 2012 at 01:21 PM 0
Share

Thanks for the reply! :)

avatar image Dissolver84 · Jun 13, 2012 at 01:22 PM 0
Share

I'll check if it works...

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

A node in a childnode? 1 Answer

Fatal Error When I Load Unity 0 Answers

Player lives script help 1 Answer

When my button is pressed the action reapeats 1 Answer


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