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 squared101 · Feb 02, 2014 at 06:13 PM · javascriptbooleanif-statementscompile-errorelse if

If...else statement with errors

I'm new to Unity, and I have a lot of trouble scripting. I always get compile errors. I made this script to open a door. When I saved it it had two compile errors:

Assets/DoorOpen.js(12,11): BCE0044: expecting }, found 'else'. Assets/DoorOpen.js(8,13): BCE0043: Unexpected token: doorOpen.

Here is the script:

 var doorOpen : boolean;
 var selectedUnits : Array = new Array();
 function OnMouseOver (){
 
 if(selectedUnits.length <= 0){
      
 if(Input.GetMouseButtonDown(0)){
     If (doorOpen = true);
     {
          transform.Rotate(0, 90, 0);
          transform.position = Vector3(1218.346, 7.315172, 902.15);
     } else {
          transform.Rotate(0, 90, 0);
          transform.Translate = Vector3(1220.346, 7.315172, 902.15);
      }
 }
 }

Someone please help!

Comment
Add comment · Show 1
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 FastTrack · Feb 02, 2014 at 06:17 PM 0
Share

If (doorOpen = true); it should be If (doorOpen == true) Remove ';' and add = ....

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by YoungDeveloper · Feb 02, 2014 at 06:15 PM

  • It's if not If

  • You are ending statement on line 8 with semicolon. Should be:

    if(){

    }

Comment
Add comment · Show 2 · 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 squared101 · Feb 02, 2014 at 07:14 PM 0
Share

Thanks, now my code looks like this:

 var doorOpen : boolean = false;
 var selectedUnits : Array = new Array();
 function On$$anonymous$$ouseOver (){
 
 if(selectedUnits.length <= 0){
      
 if(Input.Get$$anonymous$$ouseButtonDown(0)){
     if(doorOpen == true){
          transform.Rotate(0, 90, 0);
          transform.position = Vector3(1218.346, 7.315172, 902.15);
     } else {
          transform.Rotate(0, 90, 0);
          transform.Translate = Vector3(1220.346, 7.315172, 902.15);
      }
 }
 }
 }

...but I'm getting this error message: Assets/DoorOpen.js(13,45): BCE0031: Language feature not implemented: Ambiguous(Void Translate(Vector3), Void Translate(Vector3, Space), Void Translate(Single, Single, Single), Void Translate(Single, Single, Single, Space), Void Translate(Vector3, UnityEngine.Transform), Void Translate(Single, Single, Single, UnityEngine.Transform)).

avatar image fafase · Feb 02, 2014 at 07:17 PM 0
Share

Translate is a method and you are using it like a variable. What you need is a program$$anonymous$$g book.

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

One use per level question 1 Answer

Gestures in javascript 4 Answers

How can I use 1 key instead of two for toggling animation ? 2 Answers

Take boolean from other script error 1 Answer

Creating a Loadout 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