- Home /
(31,1): BCE0044: expecting }, found ''.
I'm trying to make a gun shooting script. Unity expects a } at the end of the last line. when I put it in, it expects a } at the end of the next line. It's just infinite at this point and I don't know how to fix it
#pragma strict
var bullet : gameobject;
var firepoint : GameObject;
var ammo : int = 5;
var FireMode : string = "AMR";
function Start () {
}
function Update () {
{
If(FireMode == "AMR"):
{If(input.GetMouseButtonDown(0))
(
FireOneBullet()
)
:
function (FireOneBullet)
{
Instantiate(Bullet, FirePoint.transform.position, transform.rotation);
Ammo--;
}
Answer by Thenatdude · Jun 14, 2013 at 06:39 AM
Thanks for that. I really need to get more familiar with javascript, but you've got to start somewhere.
Answer by bodec · Jun 14, 2013 at 05:45 AM
move your If statements inside the update function also remove the : from between the if statements and the function ok I was way off I pulled the script into unity and this script was so wrong there wasn't a single line right. you need to do a touvh of basic code learning then try again here is the code straighten out
#pragma strict
var bullet : GameObject;
var firePoint : GameObject;
var ammo : int = 5;
var FireMode : String = "AMR";
function Update() {
if(FireMode == "AMR"){
if(Input.GetMouseButtonDown(0)){
FireOneBullet();
}
}
}
function FireOneBullet(){
Instantiate(bullet, firePoint.transform.position,firePoint.transform.rotation);
ammo -- ;
}
you had your var done wrong if, one of the most common issues was everything was capilized
yep, most coding now is case sensitive. be very careful, also read the actual error you are getting, there is often a big clue in it, make sure when you open something with { you close it with } $$anonymous$$onoDevelop helps a lot by highlighting the "other end" of curly braces, so you can easily find the problem.
you'll get there :)
I just reread what I typed and I come across a bit harsh and that is not my intention at all I was recommended some basic coding lessons because what I saw was all syntac errors
Your answer
Follow this Question
Related Questions
Assign Default For Large Array 1 Answer
How i make this code in Unity Javascript 2 Answers
How can i make the ray cast don't go through the walls 1 Answer
Moving on Axis 1 Answer
Error Unexpected token } 1 Answer