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));
}
}
Please edit your question, highlight the code and use the 101010 button to format it correctly.
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
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!
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!
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
Follow this Question
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