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 luxidium · Nov 15, 2013 at 08:38 PM · javascripterror

UnityScript coding error:

I have a simple project. When you enter a trigger, if the textfield contains a specific word, you would move to the next scene. And its not working even know I am not getting any errors

 private var inTrigger = false;
  
 var stringToEdit : String = "";
  
 function OnTriggerEnter(other: Collider)
 {
     if (other.CompareTag("Player"))
     { 
         inTrigger = true; 
     }
 }
 
 function OnGUI()
 {
     stringToEdit = GUI.TextField (Rect (10, 10, 200, 20), stringToEdit, 23);
     if (inTrigger == true)
     {
         if (stringToEdit == "times")
         {
             Application.LoadLevel("Scene2");
         }
     }
 }
 
 function OnTriggerExit(other: Collider)
 {
     if (other.CompareTag("Player")
     {
         inTrigger = false; 
     }
 }
 
Comment
Add comment · Show 6
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 cmpgk1024 · Nov 15, 2013 at 08:39 PM 1
Share

What error is it failing with?

avatar image tanoshimi · Nov 15, 2013 at 08:44 PM 4
Share
  1. Please format your code correctly.

  2. It's JAVASCRIPT, not Java - they're completely different languages.

  3. "it don't work" - so what does happen? Does inTrigger get set to true when you enter the trigger as you expect? Does stringToEdit get set to the value you expect? Put some Debug.Log statements in there to see what's going on.

avatar image luxidium · Nov 15, 2013 at 09:09 PM 0
Share

It wont load scene2 or give any indication that any thing about it working

avatar image luxidium · Nov 15, 2013 at 09:11 PM 0
Share

I get an error that says "The referenced script on this Behaviour is missing"

avatar image luxidium · Nov 15, 2013 at 10:14 PM 0
Share

I fixed the error and it still will not work its not switching to scene2

Show more comments

1 Reply

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

Answer by clunk47 · Nov 15, 2013 at 08:58 PM

My God man. The error is self explanatory lol:

 BCE0044: expecting ), found

You're missing a closing parenthesis. ')'

Change

 if (other.CompareTag("Player")

To

 if (other.CompareTag("Player"))
Comment
Add comment · Show 9 · 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 luxidium · Nov 15, 2013 at 09:11 PM 0
Share

Thanks but I fixed it and it still dose not work

avatar image clunk47 · Nov 15, 2013 at 09:27 PM 1
Share

Dude, "does not work" isn't helping us help you at all. If you "Fixed it" it would work lol XD... That's why I edited your question in the first place. If you really need help, put some effort into your question. $$anonymous$$issing reference error you stated in a comment above usually means you've deleted a script, and didn't remove it from your object first. Have a look at all the objects in your scene and the components attached in the inspector. If a component shows as "$$anonymous$$ono Behaviour", remove it. Problem solved. If this helps, don't forget to accept the answer / vote up any other comments or answers that helped.

avatar image luxidium · Nov 15, 2013 at 10:07 PM 0
Share

What im trying to say is that im not getting any errors but it still will not work it will not switch to scene2

avatar image clunk47 · Nov 15, 2013 at 10:12 PM 0
Share

Don't put that code inside your GUI code. ONLY put GUI code in GUI Function. Place this:

 if (inTrigger == true)
 {
     if (stringToEdit == "times")
     {
         Application.LoadLevel("Scene2");
     }
 }

Inside of Update()

avatar image luxidium · Nov 15, 2013 at 11:14 PM 0
Share

Its not working would the placement of "stringToEdit = GUI.TextField (Rect (10, 10, 200, 20), stringToEdit, 23);"

matter? its currently in the Ongui function

Show more comments

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

20 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 avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Error I don't know how to fix 1 Answer

BCE0005: Unknown identifier: 'spriteRenderer'. 2 Answers

Error in distance coding 1 Answer

Javascript Compile error 2 Answers


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