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
-1
Question by asdfkor · Jul 12, 2012 at 05:18 PM · javascripterror

expecting (, found 'Update' and unexpected char: 0x200B.

p.s.i'm a newbie here, so please explain this thoroughly ;)

     #pragma strict
 var speed = 5;                         
 var rotSpeed = 120;                    
  
 
 
 var turret : GameObject;            
  
 
 
 var power = 600;               
 
 var bullet : Transform;
 
 var explosion: Transform;   
      
 var snd : AudioClip;            
 
 
 function Update() {
 
     var amtToMove = speed * Time.deltaTime;      
 
     var amtToRot = rotSpeed * Time.deltaTime;         
     
 
  
 
 
     var front = Input.GetAxis("Vertical");                   
 
     var ang = Input.GetAxis("Horizontal");               
 
    var ang2 = Input.GetAxis("MyTank");            
 
 
  
 
 
     transform.Translate(Vector3.forward * front * amtToMove);           
 
     transform.Rotate(Vector3(0, ang * amtToRot, 0));                         
 
    turret.transform.Rotate(Vector3.up * ang2 * amtToRot);              
 
  
 
 function Update(); {
 
    ...................;
 
 
    
 
     if (Input.GetButtonDown("Fire1")) {
 
       var spPoint = GameObject.Find("spawnPoint");                                        
 
       Instantiate(explosion, spPoint.transform.position, Quaternion.identity);      
 
       AudioSource.PlayClipAtPoint(snd, spPoint.transform.position);                
 
       var myBullet = Instantiate(bullet, spPoint.transform.position, Quaternion.identity);
 
 
         myBullet.rigidbody.AddForce(spPoint.transform.forward * power);
         }

And now the errors...

Assets/jstank/jstank.js(73,1): BCE0044: expecting }, found ''.

Assets/jstank/jstank.js(55,5): BCE0043: Unexpected token: ..

Assets/jstank/jstank.js(55,4): BCE0043: Unexpected token: ..

Assets/jstank/jstank.js(53,10): BCE0044: expecting (, found 'Update'.

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 DaveA · Jul 12, 2012 at 08:06 PM

You have garbage. Delete this:

 function Update(); {
 
    ...................;
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 blackmethod · Jul 12, 2012 at 08:16 PM

Okay. Lots wrong here, no offence. You're missing tons of curly-braces. And never put a semi-colon before a curly brace. Otherwise you're essentially telling it to stop the function but keep going. Of course it's confused.

  #pragma strict
 var speed = 5;                         
 var rotSpeed = 120;                    
 
 
 
 var turret : GameObject;            
 
 
 
 var power = 600;               
 
 var bullet : Transform;
 
 var explosion: Transform;   
 
 var snd : AudioClip;            
 
 
 function Update() {
 
     var amtToMove = speed * Time.deltaTime;      
 
     var amtToRot = rotSpeed * Time.deltaTime;         
 
 
 
 
 
     var front = Input.GetAxis("Vertical");                   
 
     var ang = Input.GetAxis("Horizontal");               
 
    var ang2 = Input.GetAxis("MyTank");            
 
 
 
 
 
     transform.Translate(Vector3.forward * front * amtToMove);           
 
     transform.Rotate(Vector3(0, ang * amtToRot, 0));                         
 
    turret.transform.Rotate(Vector3.up * ang2 * amtToRot);              
 
 
 
 
 
 
 
     if (Input.GetButtonDown("Fire1")) {
 
       var spPoint = GameObject.Find("spawnPoint");                                        
 
       Instantiate(explosion, spPoint.transform.position, Quaternion.identity);      
 
       AudioSource.PlayClipAtPoint(snd, spPoint.transform.position);                
 
       var myBullet = Instantiate(bullet, spPoint.transform.position, Quaternion.identity);
 
 
         myBullet.rigidbody.AddForce(spPoint.transform.forward * power);
         }
     }


Code is very messy but try that, it might work.

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 blackmethod · Jul 12, 2012 at 08:18 PM 0
Share

As for what you have, I don't see why you have 2 update functions, you only need one.

And putting " ...................;" it's expecting a command. The only way you can put something without having it affecting the code is making sure to put "//" before it.

avatar image asdfkor · Jul 13, 2012 at 05:46 AM 0
Share

thanks a million, nathan! the game is quite fluently running but the tank don't know how to shoot:( there's the error... help me please

UnassignedReferenceException: The variable explosion of 'jstank' has not been assigned. You probably need to assign the explosion variable of the jstank script in the inspector. UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/BuildAgent/work/b0bcff80449a48aa/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:44) UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at C:/BuildAgent/work/b0bcff80449a48aa/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:53) jstank.Update () (at Assets/jstank/jstank.js:53)

avatar image blackmethod · Jul 13, 2012 at 06:29 AM 0
Share

From what you posted the only solution I have is... When you apply the script to the gameobject in the "inspector" it becomes active, but with your script it's trying to activate something that isn't there if you get me. You have an explosion set to happen, but the explosion effect itself isn't part of the script. So if you were to click on the item in the inspector with the script on it you would get something like this.

It would have all the usual gameobject info, then scroll down to where it shows the script in the object, there should be a blank spot that you can drag and drop an explosion prefab animation onto.

Prefab = Predefined object or set of objects that can be dropped into the game at any time

Inspector = The box in the bottom left showing objects in the scene

Gameobject = Item that you can see in the inspector, that is in the scene

Hope I helped you out, if I did please thumbs up my first post!

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

6 People are following this question.

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

Related Questions

BCE0043: Unexpected token: }. 1 Answer

Detecting Webplayer's errors from Javascript 0 Answers

Raycast problems 2 Answers

Windows Script error upon opening a new javascript behavior script. 4 Answers

Error message: "Unexpected token *" javascript - wha? 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