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 Devlus · Feb 01, 2011 at 09:00 PM · errorsyntax-errorbce0044

script error GUI super simple code

var score = 0;

guiText.text = "Score: "+score;

function OnCollisionEnter(hit : Collider) { if(hit.gameObject.name == "bug enemy pre(Clone)"){ { score += 5; } } }

It's pretty straight forward, but basically on collision with the enemy object, I want the score to move up by 5. I'm getting an error that says "Assets/score.js(9,11): BCE0044: expecting :, found '+='." I'm sure this is a super simple error, and I have tried changing some things around, but this seems like the smoothest solution, so a little help would be very much appreciated. oooooo, and anyone who gives an answer (that solves my problem) can call me an idiot! And its JS...

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by FLASHDENMARK · Feb 01, 2011 at 09:05 PM

Is this helping ?:

var score = 0;

guiText.text = "Score: "+score;

function OnCollisionEnter(hit : Collision) { if(hit.gameObject.name == "bug enemy pre(Clone)") { score += 5; } }

Not sure if this is fixing it,but you had brackets to many.

Comment
Add comment · Show 1 · 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 Devlus · Feb 01, 2011 at 09:14 PM 0
Share

w/o the brackets i get an additional 3 errors

avatar image
0

Answer by Eric5h5 · Feb 01, 2011 at 09:03 PM

"score ++ 5" isn't valid syntax. "score += 5"

Comment
Add comment · Show 1 · 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 Devlus · Feb 01, 2011 at 09:08 PM 0
Share

ya that was one of the things i played with, but with that in place i updated the error in the post

avatar image
0

Answer by Devlus · Feb 01, 2011 at 09:21 PM

Ok using both of your advice i fixed it to an un-bugged version! thanks... i'm not sure who to mark correct, because you both were right... anyway here is the working code

var score = 0;

guiText.text = "Score: "+score;

function OnCollisionEnter(hit : Collision){ if(hit.gameObject.name == "bug enemy pre(Clone)"){ score += 5; } }

whether this code works or not is for another day, anyway thanks all

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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

I need help with an error 1 Answer

script not working 2 Answers

Script error. Please Help! 4 Answers

BCE0044: expecting ':' found ';' 1 Answer

ShopScript.Js(49,17): BCE0044 expecting :, found GUI. 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