Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Thenatdude · Jun 14, 2013 at 05:42 AM · javascript

(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--;
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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 -- ;
 }
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image bodec · Jun 14, 2013 at 06:28 AM 0
Share

you had your var done wrong if, one of the most common issues was everything was capilized

avatar image bubzy · Jun 14, 2013 at 06:34 AM 0
Share

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 :)

avatar image bodec · Jun 14, 2013 at 06:36 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges