#i have three

1 messages · Page 1 of 1 (latest)

hushed tapir
#

Yes. One is closing the aim method, one is closing the class these methods are in. The third one is unnecessary, unless this is a nested class or you are using a namespace (I'm assuming you aren't), and you do not have a closing brace on Shoot.

amber estuary
#

just to be sure, when you say brace, you mean this? {}

hushed tapir
#

Yes

amber estuary
#

i am not using namespace for shoot and aim

#

when i remove the brace, unity give me a error, requiring the brace i removed

hushed tapir
#

Yes. Removing it is not enough. That bracket is needed, but at the end of Shoot, not at the very end.

amber estuary
#

i mean, when i do what you say it give me a couple of errors, unless i did it wrong

hushed tapir
#

Have you added the closing bracket at the end of Shoot?

amber estuary
#

void Shoot()
{
if (Input.GetButtonDown("Fire1") && ammoAmount > 0)
{
Instantiate(bullet, SpawnBullet.position, transform.rotation);
shootFx.Play();
ammoAmount -= 1;
ammo[ammoAmount].gameObject.SetActive(false);
}
}
if (Input.GetKey(KeyCode.R))
{
ammoAmount = 3;
for (int i = 0; i <= 2; i++)
{
ammo[i].gameObject.SetActive(true);
}
}

#

it's like this

hushed tapir
#

You are closing the method too early. Remove the bracket you added (before if(Input.GetKey(KeyCode.R)) again and put it at the end of what you just posted. After ammo[i].. etc

#

I just realized I switched from saying brace to bracket. Sorry, I mean the same thing.

amber estuary
hushed tapir
#

Mate.. you removed 2 braces and put them nowhere.

amber estuary
#

at the very bottom?

#

i put the 2 braces there

hushed tapir
#

It is genuinely worse than before. Ignore your errors for a second, go through your class and check if you can make sense of where a opening brace should be and where a closing brace should be. Indent your code properly, it will make it easier.
Otherwise I recommend a basic c# course.