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 Alienjesus · Mar 28, 2011 at 05:52 PM · errortagif-statementsbce0044

Whats wrong with this code? "expecting :, found '=' " error.

OK, this error has been bugging me for some time now, and I just can't figure it out. Please someone point out the error to me, because as far as I know, my code is correct. I added an extra if statement to check for an objects tag, and suddenly, the code which worked before throws up an error message - not even the new code itself!

The code previously parented a raycast hit object to the controlled object and allowed you to move it around. I am trying to check for tags to see if an object is moveable, or if it is a switch.

Heres the code. I've put in a note where the error occurs, and another note where the newly entered code in. All help is appreciated!

var hasObject: boolean = false; var otherThing: Transform;

 function Update () {


 var fwd = Camera.main.transform.forward;
 var hit :  RaycastHit;
 var LayerMask = (1<<9) | (1<<10);

 Debug.DrawRay(camera.main.transform.position, (transform.position-camera.main.transform.position) * 50, Color.red);

 If (Input.GetButtonDown ("Fire2"))
 {
         if (!hasObject)
         {
                 if (Physics.Raycast(camera.main.transform.position, (transform.position-camera.main.transform.position), hit, 75, LayerMask))
                 {
                 otherThing = hit.transform;

//The next line is the new line of code which is causing the error. if (otherThing.tag("Moveable")); { //The line below is where the error is being thrown up. otherThing.rigidbody.isKinematic = true; otherThing.rigidbody.detectCollisions = false; otherThing.transform.position.z = 0; otherThing.parent = transform; otherThing.Find("Glowblock").light.enabled = true; hasObject = true; //This next section is also new. }else if { (otherThing.tag("switchable")); Debug.Log ("This is a switch"); } } }else { otherThing.rigidbody.isKinematic = false; otherThing.rigidbody.detectCollisions = true; transform.DetachChildren(); otherThing.transform.position.z = 0; otherThing.Find("Glowblock").light.enabled = false; hasObject = false; } }

 }

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
3
Best Answer

Answer by Eric5h5 · Mar 28, 2011 at 05:57 PM

You have a ";" after the if statement.

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 Alienjesus · Mar 28, 2011 at 06:18 PM 0
Share

D'oh! Thanks, that cleared up that error. Trust it to be something so obvious. Now I just need to figure out what format the if statements need to be in, because they aren't working either >_<.

"It is not possible to invoke an expression of type 'String'."

avatar image swquinn · Mar 28, 2011 at 06:26 PM 1
Share

@Alienjesus: Take a look at your syntax for the if statement, you have the keyword capitalized. That might be part of your problem (I posted below citing this as a potential compilation issue)

avatar image Eric5h5 · Mar 28, 2011 at 07:53 PM 1
Share

@Alienjesus: You probably mean to use CompareTag; if otherThing.tag("$$anonymous$$oveable") isn't correct syntax. You could see if tag == "$$anonymous$$oveable", but CompareTag is better.

avatar image
1

Answer by swquinn · Mar 28, 2011 at 06:24 PM

As Eric5h5 says above, you have a semi-colon that is causing havoc with your conditional statement (if-block). I did also notice that you have a capitalized "if" statement immediately after your Debug output:

Debug.DrawRay(camera.main.transform.position, (transform.position-camera.main.transform.position) * 50, Color.red);

If (Input.GetButtonDown ("Fire2")) { ... }

should be (note the lower case "if")...

Debug.DrawRay(camera.main.transform.position, (transform.position-camera.main.transform.position) * 50, Color.red);

if (Input.GetButtonDown ("Fire2")) { ... }

Which may also cause you compilation problems for you, I know C# expects the if syntax to be lower case, and I believe JavaScript does as well. Not sure about Boo off hand though.

I'm not sure if it was just a typo when posting your code, or if the keyword is capitalized in your actual code as well. Just thought I'd give you a heads up.

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 Alienjesus · Mar 28, 2011 at 06:28 PM 0
Share

Thanks for the heads up, although that one was actually a typo when i posted it here. I appreciate it though!

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

Newb question 2 Answers

BCE0044 error 0 Answers

I need help with an error 1 Answer

error help 2 Answers

Error is: BCE0044: expecting '"', found 'r'. 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