• 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 user-10287 (google) · May 04, 2011 at 06:54 AM · errorsyntax-errorbce0043

java script error

i keep getting this error "Assets/scripts/shootsemiauto.js(7,121): BCE0043: Unexpected token: )."

var bulletPrefab : Transform;</p> <p>function Update () {</p> <p>if(Input.GetButtonDown(LeftMouseButton)) { var bullet = Instantiate (bulletPrefab, GameObject.Find ("spawnPoint").Transform.position , Quaternion.identity,);</p> <pre><code>bullet.rigidbody.AddForce(transform.forward * 200) } </code></pre> <p>}

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
2

Answer by Jean-Fabre · May 04, 2011 at 07:04 AM

Hi,

You had numerous errors actually.

Here is the code fixed:

var bulletPrefab : Transform;

var spawnReference : Transform ;

function Update () {

 if ( Input.GetMouseButtonDown(0) ){

     if (spawnReference!=null){
         spawnPoint = spawnReference.position;
     }else{
         Debug.LogError("WArning: no spawnReference declared");
         return;
     }
     var bullet = Instantiate (bulletPrefab,spawnPoint, Quaternion.identity);
     bullet.rigidbody.AddForce(transform.forward * 200);
 }

}

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
1

Answer by Thomas 7 · May 04, 2011 at 07:03 AM

There's a "," behind Quaterion.identity

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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Unexpected Token: Collider. 1 Answer

SwipeControl package error in unity iPhone 1.7 1 Answer

Converted a script from C# to JS, Unexpected Token: .. What did I do? 1 Answer

Unexpected Token }. 1 Answer

3 java errors on a basic shooting script? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges