Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
Question by Joebear · Dec 01, 2015 at 08:27 PM · javascripterrorshootingpublicrecognition

Expecting EOF found 'Public'

I asked this question before, and it was answered. The problem was fixed. However, there's a second "Public" in the script that isn't recognized. I'm out of ideas now. I'm a beginning JavaScript user. This script is for a 'click-shoot' kind of thing. This is the script:

 #pragma strict
 
     var myInt : int = S;
 
 function MyFunction(number : int) : int
 {
     var ret = myInt * number;
     return ret;
     }
         
  public : Rigidbody;
  
   projectile;
           {
       }
  public float speed = 20;
 
  void Start () {
      
  }
  
  
  void Update () {
      
      if (Input.GetButtonDown("Fire1"))
      {
          Rigidbody;
           instantiatedProjectile = Instantiate(projectile,
                                                         transform.position,
                                                         transform.rotation)
              as Rigidbody;
          
          instantiatedProjectile.velocity = transform.TransformDirection(new Vector3(0, 0,speed));
          
      }
  }


Comment
Add comment · Show 2
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 Dave-Carlile · Dec 01, 2015 at 08:33 PM 0
Share

Please edit your question, highlight the code and use the 101010 button to format it correctly.

avatar image Joebear Dave-Carlile · Dec 01, 2015 at 10:00 PM 0
Share

Okay > okay

2 Replies

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

Answer by pekalicious · Dec 02, 2015 at 11:21 PM

This script has a lot of issues. It seems that there are a lot of things written in c# but the script is in javascript.

For example,

 public float speed = 20f;

Is c#. The javascript way would be

 var speed : float = 20;

Also, you have this statement which doesn't mean anything:

 public : Rigidbody;
  
 projectile;
        {
    }

Brackets are unnecessary and projectile is out of place. You probably want

 var projectile : Rigidbody;

Then you have Update and Start functions written in c#

 void Update()

Should be

 function Update()

Finally, you have placed a semicolon that doesn't belong there:

 Rigidbody;
        instantiatedProjectile = Instantiate(projectile,
                                                      transform.position,
                                                      transform.rotation)
           as Rigidbody;

should be

 Rigidbody
        instantiatedProjectile = Instantiate(projectile,
                                                      transform.position,
                                                      transform.rotation)
           as Rigidbody;

I highly recommend watching some beginner tutorials. Copy pasting without understanding basic code syntax will get you nowhere. There are many tutorials here to get you started http://unity3d.com/learn/tutorials/topics/scripting

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 Joebear · Dec 03, 2015 at 02:26 AM 0
Share

Wow, thanks I thought maybe the way to really get started was kind of copy a script then advance upon it, but I'm pretty sure the script I got in the first place was C#. That also obviously wasn't the case with starting Your post was really helpful. I'll check out those tutorials. Thanks!

avatar image
0

Answer by toddisarockstar · Dec 02, 2015 at 03:37 AM

everytime you see "Expecting EOF found" it means you are missing a bracket like this }. haha. count em up and add where needed. the error the line shows on is not usually where the missing bracket is sopposed to be!

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 Joebear · Dec 02, 2015 at 10:12 PM 0
Share

I'm not sure where the bracket should be...? I put brackets around most all of the functions and sections. I wouldn't be asking this if I didn't have any other ideas. Thanks for the information, though! It's definitely going to help on my future projects,

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

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

Related Questions

CS0103 and CS0246 with "public Text text;" 0 Answers

how to fix error CS1525: Unexpected symbol `public' and 'private' 0 Answers

Enemy AI for Shooting Game 1 Answer

Function Update not working 1 Answer

Animation Types Won't Play 0 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