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 MP0732 · Jun 19, 2012 at 03:35 PM · semicolon

"Insert a semicolon at the end" error despite existing semicolon

I've browsed through the responses to previous instances of this problem and I cannot find an answer that resolves the error in my own script. So I am re-posting what I know is a common and probably obvious error. Thanks in advance for the help.

The errors begin toward the bottom, beginning with the line that says " }else(attackElf.tag == "youngElf")"

     import System.Linq;
 
 
 private var availablePositions : List.<Transform>;
 //Allows assignation through the Inspector of the two possible positions from which the Spawn function will
 //later randomly select.
 var blackElves : GameObject[];
 //Populates array with enemy elves
 var fatElfCompanion : GameObject;
 var shortElfCompanion : GameObject;
 var strongElfCompanion : GameObject;
 var smartElfCompanion : GameObject;
 var fastElfCompanion : GameObject;
 var toughElfCompanion : GameObject;
 var uglyElfCompanion : GameObject;
 var youngElfCompanion : GameObject;
 //links each enemy elf with a partner
 
 
 function Start () 
 {
 availablePositions = attackPositions.ToList();
 }
 //lists available attack positions of enemy elf and his partner.
 
 function Update () {
 
 }    
 
 function OnTriggerEnter(col : Collider)
 {
     if(col.gameObject.tag == "Player")
     {
         yield new WaitForSeconds(3.0);
         Spawn;
     }
 }
 //When player enters this zone, the function "Spawn" is called after three seconds.
 
 function Spawn ()
 {
     var position = availablePositions[Random.Range(0, availablePositions.Length)];
     availablePositions.Remove(position);
     //One position is selected at random from two possibilities. The position selected is removed from set of possibilities.
     var attackElf = Instantiate(blackElves[(Random.Range(0, blackElves.Length))], position.position, Quaternion.identity);
     //One of the enemy elves is selected from the array and named "attack Elf". It is assigned to the randomly selected position.
     if(attackElf.tag == "fatElf")
     {
         var companionElf = Instantiate(fatElfCompanion, availablePositions[0].position, Quaternion.identity);
     }else if(attackElf.tag == "shortElf")
     {
         var companionElf = Instantiate(shortElfCompanion, availablePositions[0].position, Quarternion.identity);
     }else if(attackElf.tag == "strongElf")
     {
         var companionElf = Instantiate(strongElfCompanion, availablePositions[0].position, Quaternion.identity);
     }else if(attackElf.tag == "smartElf")
     {
         var companionElf = Instantiate(smartElfCompanion, availablePositions[0].position, Quaternion.identity);
     }else if(attackElf.tag == "fastElf")
     {
         var companionElf = Instantiate(fastElfCompanion, availablePositions[0].position, Quaternion.identity);
     }else if(attackElf.tag == "toughElf")
     {
         var companionElf = Instantiate(toughElfCompanion, availablePositions[0].position, Quaternion.identity);
     }else if(attackElf.tag == "uglyElf")
     {
         var companionElf = Instantiate(uglyElfCompanion, availablePositions[0].position, Quaternion.identity);
     }else(attackElf.tag == "youngElf")
     {
         var companionElf = Instantiate(youngElfCompanion, availablePositions[0].position, Quaternion.identity);
     }
 }
 
 
 //A second, "Companion Elf" is instantiated at the other remaining position. It is not selected at random. It
 //must be the concomitant of the "Attack Elf" previously selected.
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
Best Answer

Answer by SarperS · Jun 19, 2012 at 03:38 PM

You can't put an expression in an "else" block. it must be else only or an "else if(expression)".

Thus "else(attackElf.tag == "youngElf")" is causing the error. Change it to else if(attackElf.tag == "youngElf")"

Comment
Add comment · Show 1 · 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 MP0732 · Jun 19, 2012 at 03:56 PM 0
Share

Yeah, that fixed it. Thank you very much.

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

Quick error in my code? 2 Answers

Script says I need semicolons. I already have them. 1 Answer

Extra semicolon??? 1 Answer

; expected insert semicolon at the end 2 Answers

No semicolon?! 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