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?