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
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;
}
}
}