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
1
Question by taylorsnead · Apr 24, 2011 at 04:26 AM · errorsyntax-errorbce0043unexpected-token

Converted a script from C# to JS, Unexpected Token: .. What did I do?

So, I have this script that I had, but then began modifying. Since it was in C# (it was originally not mine, I just used it to start off(I'm mostly new to Unity, and development in general, although I have worked much with 2D before and have very quickly familiarized scripting syntax)), I had a bit of trouble adding my own spread modifier. I chose to convert it to UnityScript, so that I would be able to more quickly do things with it. I haven't been able to test it, but I can work all translating kinks out after I fix this. I'm on the very end:

   function ShowHits(RaycastHit.hit)
{
    switch (hit.transform.tag)
    {
        case "bullet":
            // do nothing if 2 bullets collide
            break;
        case "Player":
            // add blood effect
            break;
        case "wood":
            // add wood impact effects
            break;
        case "stone":
            // add stone impact effect
            break;
        case "ground":
            // add dirt or ground  impact effect
            break;
        default: // default impact effect and bullet hole
            Instantiate(impactEffect, hit.point + 0.1f * hit.normal, Quaternion.FromToRotation(Vector3.up, hit.normal));
            newBulletHole = Instantiate(bulletHole, hit.point, Quaternion.FromToRotation(Vector3.up, hit.normal));
            newBulletHole.transform.parent = hit.transform;
            break;
    }
}

But when it compiles in Unity, the only error is this: Assets/My Assets/Scripts/Gun.js(509,34): BCE0043: Unexpected token: ..

Line 509 being "function ShowHits(RaycastHit.hit)", the problem is the period between RaycastHit and hit, but there shouldn't be. There were no problems with other instances of RaycastHit.hit and RaycastHit.hits in the script, so, considering this just bewildered me, does anyone know what's going on here? (I have looked and looked around, not finding an answer, so don't flame me if I'm blind)

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

1 Reply

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

Answer by Eric5h5 · Apr 24, 2011 at 04:44 AM

You need to define the type of variables used in functions.

function ShowHits (hit : RaycastHit)
Comment
Add comment · Show 4 · 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 taylorsnead · Apr 24, 2011 at 04:51 AM 0
Share

That creates a whole slew of errors from the entire script. I'll look through them, but it seems that alot of things relied on that line being structured how it was o_O

avatar image taylorsnead · Apr 24, 2011 at 04:52 AM 0
Share

"The name 'string' does not denote a valid type ('not found'). Did you mean 'Boo.Lang.Compiler.IO.StringInput'?" is the error for 4 of them, with different names. They are all "does not denote a valid type"

avatar image Eric5h5 · Apr 24, 2011 at 05:27 AM 1
Share

The line had incorrect syntax, so nothing relied on it; you're just seeing the other errors that were already there. There's no 'string' in JS, it's 'String', but that's not related to the error in question.

avatar image taylorsnead · Apr 24, 2011 at 05:35 AM 0
Share

Ah, thank you for clearing that up. Sometimes I just get effed with capitols and finite syntax like that. I guess I'm just a sucky translator.

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

Unexpected token: .. 1 Answer

Unexpected Token: Collider. 1 Answer

Unexpected Token }. 1 Answer

what is an unexpected token 1 Answer

unexpected token 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