- Home /
";" expected. Insert a semicolon at the end
Hi, mi name is Mickey, and im a noob with java, so, i have a problem with this code
function Start ()
{
int Bullets;
Bullets = 8;
}
function Update ()
{
if(Input.GetMouseButtonDown(0))
{
if (Bullets > 0)
{
Debug.Log("Disparo");
animation.play ("Disparo");
Bullets = Bullets - 1;
}
else
{
Debug.Log("Sin Balas...Recargando");
animation.play("Recarga");
Bullets = 8;
}
}
}
if somebody can help me with this error, im going to be really grateful
Answer by AlucardJay · Mar 17, 2013 at 09:44 AM
I just formatted your code as it was impossible to read. Now I can, there are a few major problems with your script.
In you Start function, you have used C# to declare a variable. And also you have made this variable local, so it doesn't exist outside the Start function, which will have your Update giving errors.
There should be a capitol P in animation.Play
So, make your Bullets variable global, and correctly declare it in uJS :
#pragma strict
var Bullets : int = 8;
function Start ()
{
}
function Update ()
{
if(Input.GetMouseButtonDown(0))
{
if (Bullets > 0)
{
Debug.Log("Disparo");
animation.Play ("Disparo");
Bullets = Bullets - 1;
}
else
{
Debug.Log("Sin Balas...Recargando");
animation.Play("Recarga");
Bullets = 8;
}
}
}
As Fattie stated, you should modify your na$$anonymous$$g convention of variables too. variable names should be lowercase or camelCase :
var bullets : int = 8;
var myBullets : int = 8;
note where the lower case and capitol letters are.
$$anonymous$$any thanks Fattie =]
Ohh, ok, thank you, i´m really grateful, i always have problems with the variables, thank you, for the answers
Your answer
Follow this Question
Related Questions
Insert Semicolon error 1 Answer
insert a semicolon at the end?? 1 Answer
Insert Semicolon error 1 Answer
; expected insert semicolon at the end 2 Answers
insert semicolon error 3 Answers