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
-3
Question by Hawkezley · Oct 19, 2013 at 10:37 PM · error

How do I fix this error in my code

Please help the error says this when I save the code: alt text

This is the code that is used can anyone help me? alt text

17e8142e2a78492de03ab107c164ada0.png (3.6 kB)
faa7adb1f09cc2fa91a2eec28a7a9d8a.png (12.2 kB)
Comment
Add comment · Show 3
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 Kiloblargh · Oct 20, 2013 at 01:49 AM 1
Share

The numbers in the parentheses tell you that on line 3, 17 characters from the start of the line, the compiler ran into something that did not make sense. And usually the reported error comes after the actual mistake. You really didn't try very hard to debug your own problem.

avatar image Benproductions1 · Oct 21, 2013 at 03:28 AM 1
Share

@Hawkezley If someone answered your question, please accept their answer. If you don't know how, watch the tutorial video on the right

avatar image Eric5h5 · Oct 21, 2013 at 03:49 AM 2
Share

Post code as code, not as an image. You can't copy and paste an image into a code editor.

2 Replies

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

Answer by Benproductions1 · Oct 19, 2013 at 10:55 PM

Hello,

You seem to not understand UnityScript syntax in defining variables. It goes like this:

 var name:type = value; //with value being optional

In your script on line 3 you do this though:

 var TheDamage ; int : 50;

which is just plain wrong syntax. Follow the syntax and you won't get any errors

Another note is that the rest of your program won't compile either and give you a whole ton of other errors:

 function update() (
 {if (Input.GetButtonDown("Fire1")
     {var hit:RaycastHit;
         if (Physics.Raycast(/*etc*/));
         (Distance = hit.distance;
            hit.transform.SendMessage(/*etc*/);)
 }

If you write this in a more readable format you get:

 function update() ({
     if (Input.GetButtonDown("Fire1") {
         var hit:RaycastHit;
         if (Physics.Raycast(/*etc*/)); {
             Distance = hit.distance;
             hit.transform.SendMessage(/*etc*/);)
 }

I'm sure you can figure out what you did wrong there. Just to make it a little easier, I'll make a check list for you:

-2x random ( or ) that shouldn't be there
-1x missing ( or )
-2x missing { or }
-1x random ; that shouldn't be there

Hope this helps,
Benproductions1

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 Hawkezley · Oct 21, 2013 at 06:24 AM 0
Share

Thank yo very much I'm new to this s this website is amazing and thank you again.

avatar image
-1

Answer by roflbuddy · Oct 19, 2013 at 10:57 PM

 var TheDamage : int = 50;
 var Distance : float;
 
 function Update () {
 if(Input.GetButtonDown("Fire1")){
 var hit : RaycastHit;
 if (Physics.Raycast (transform.position, transform.TransofmDirection(Vector3.forward), hit));
 
 Distance = hit.distance;
 hit.transform.SendMessage("ApplyDamage", TheDamage, SendMessageOptions.DontRequireReceiver);
    }
 }
Comment
Add comment · Show 5 · 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 Benproductions1 · Oct 19, 2013 at 10:59 PM 2
Share

I'd like to note that posting the fixed code will NOT help the OP. This answer does not comply with the FAQ and I will therefore give a -1

Also you should learn to indent ;)

avatar image robertbu · Oct 19, 2013 at 11:10 PM 0
Share

@Benproductions1 - while I agree with your sentiments about education, @roflbuddy did pickup on one bug you missed ;)

avatar image Benproductions1 · Oct 19, 2013 at 11:42 PM 0
Share

The situation of the OP is unknown, so the lack of capitalization of update might or might not have been deliberate and it is actually called from another script. That's why I left it out ;)

avatar image roflbuddy · Oct 20, 2013 at 04:46 PM 0
Share

I am sorry guys i understand. But Benproductions1 did point out everything that was wrong, so i just made it easier for the OP. But i wont do it again :)

avatar image Hoeloe · Oct 20, 2013 at 04:51 PM 0
Share

@roflbuddy: Giving people code makes it easier for them in the short term, but also means they will likely just copy and paste it, meaning they'll be back in an hour with another, very similar question. It might be slightly easier for them in the short term, but not better for them.

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

18 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

Related Questions

Warning: "Can not play a disabled audio source" 1 Answer

What Am I doing wrong? 1 Answer

Animation script error 1 Answer

Console Error 1 Answer

Weird compiler error code 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