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 Snivy · Jan 31, 2013 at 10:00 PM · error

How to fix this error, source included.

Unity is giving me the error: "Assets/SnakeMovement.js(15,28): BCE0044: expecting :, found ';'." In my code, it looks like this:

 #pragma strict
 var Rats : GameObject;
 private var NumberofRats : int;
 var SnakeBody : GameObject;
 private var LastPiece : GameObject;
 var lives : int;
 var ShowHighscore : boolean;
 
 function Start () 
 {
     ShowHighscore = false;
     var i : int = 0;
     while(i<10);
     {
         PlaceRats();
         i++;
     }
     Rats = 0;
     LastPiece = GameObject;
     if(PlayerPrefs.GetInt("Rats")) 
     {
         PlayerPrefs.GetInt("Rats", 1);
     }
     if(PlayerPrefs.GetInt("lives")) 
     {
         if(PlayerPrefs.GetInt("lives") i=0) 
         {
             PlayerPrefs.GetInt("lives", 3);
         }
     }
     lives = PlayerPrefs.GetInt("lives");
 }
 
 function Update () 
 {
     Transform.Translate(Vector3(0, 0, 0.06));
     if(Input.GetKeyUp(KeyCode.RightArrow))
     {
         Transform.Rotate(Vector3(0, 90, 0));
     }
     else(if(Input.GetKeyUp(KeyCode.LeftArrow))
     {
         Transform.Rotate(Vector3(0, -90, 0));
     }
     if((Time.time/10) < 0.001)
     {
         PlaceRats ();
     }
 }
 
 function PlaceRats()
 {
     Rats:GameObject = Instantiate(Rats, Vector3(Random.Range(-25,25), 2.2, Random.Range(-25,25)), Quaternion.identity);
     NumberofRats.name = "Rats";
 }
 
 function OnTriggerEnter(col:Collider)
 {
     if(col.GameObject. name == "Food")
     }
         Rats++;
         addBodyPart();
         Destroy(col.GameObject);
         PlaceRats();
     }
     if(col.GameObject.name == "SnakeBody")
     {
         Application.LoadLevel(Application.LoadLevel);
         var oldLives = PlayerPrefs.GetInt("lives");
         PlayerPrefs.SetInt("lives", oldLives-1);
     }
 }
 function addBodyPart()
 {
     var ExtraBodyPart : GameObject = Instantiate(SnakeBody, transform.position-(Rigidbody.velocity*100), Quaternion.identity);
     ExtraBodyPart.name = "SnakeBody";
     ExtraBodyPart.GetComponent<SmoothFollow().target = ExtraBodyPart;
     ExtraBodyPart = SnakeBody;
 }

Could you guys tell me what I'm doing wrong?

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
2
Best Answer

Answer by Julien-Lynge · Jan 31, 2013 at 10:23 PM

At line 15, character 28, the compilers is expecting a ':', and instead found a ';'. That's what your error message means.

Assets/SnakeMovement.js(15,28): BCE0044: expecting :, found ';'.

Comment
Add comment · Show 8 · 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 Loius · Jan 31, 2013 at 10:54 PM 1
Share

Your while loop has a semicolon after it and it should not.

Whenever you get an "expected ;" error message, it's usually on a line after where the actual problem is.

avatar image Snivy · Jan 31, 2013 at 11:11 PM 0
Share

Now it's saying that i=0 isn't allowed where it is, is there something wrong with the lives call?

avatar image Wolfram · Jan 31, 2013 at 11:16 PM 0
Share

What do you expect the "i=0" in line 26 to do?

avatar image Snivy · Jan 31, 2013 at 11:18 PM 0
Share

It was supposed to set the lives back to 3 if you have 0, but that was my own stupidity.

avatar image Wolfram · Jan 31, 2013 at 11:23 PM 0
Share

Does that mean you solved the problem? It also seems you are unsure on how to use PlayerPrefs.GetInt() properly, I suggest googling for some examples where it is used.

@vicenti: You should convert your comment to an answer, as it is the answer to his original question.

Show more comments

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

12 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

Related Questions

A node in a childnode? 1 Answer

My C# script brings back no results in the console 1 Answer

Why am I getting a parsing error? 1 Answer

dont work maxdistance 0 Answers

BCE0043 unexpected token! pls help. 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