- Home /
True False What am I doing wrong.
I seem to be on a roll today with my questions. Alright so Im working on making it when the character is out of mags he can no longer shoot. I think I am just writing it funny or something small.
private bool outofmags = false;
This is in my void update V V V
if (VariableScript.pistolclip <= 0)
{
outofmags = true;
}
if (VariableScript.pistolclip >= 1)
{
outofmags = false;
}
Later on ....
if ( Input.GetMouseButtonDown(0) )
{
if outofmags == false;
{
HandleBullets();
}
if outofmags == true;
{
// ignore this here, Ill just make it play a sound or something instead of calling another function that doesn't shoot
}
}
I get the error Assets/Scripts/AIscript.cs(129,44): error CS1525: Unexpected symbol outofmags', expecting
('
I know it tells me what It is expecting I am just unsure on how to fix it.
Hopefully you get what I want it to do.
Im learning a lot from my questions cheers guys.
FYI: You should be using 'else' in s$$anonymous$$d of the second 'if' in both code fragments.
$$anonymous$$ will do, Did you negative my question?, honestly don't know why or who is doing it to my questions. Im no coder, just learning
Answer by Justin Warner · Dec 12, 2010 at 05:45 AM
Your if statements is wrong in the second piece....
You have:
if ( Input.GetMouseButtonDown(0) )
{
if outofmags == false;
{
HandleBullets();
}
if outofmags == true;
{
// ignore this here, Ill just make it play a sound or something instead of calling another function that doesn't shoot
}
}
It SHOULD be:
if ( Input.GetMouseButtonDown(0) )
{
if (outofmags == false)
{
HandleBullets();
}
if (outofmags == true)
{
// ignore this here, Ill just make it play a sound or something instead of calling another function that doesn't shoot
}
}
Good to ask though, always ask, no matter how small the question is =).
Aight, good to hear... Off for the night, haha, have a good night =).