- Home /
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?
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 ';'.
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.
Now it's saying that i=0 isn't allowed where it is, is there something wrong with the lives call?
It was supposed to set the lives back to 3 if you have 0, but that was my own stupidity.
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.
Your answer
Follow this Question
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