- Home /
Unexpected token and expected eof errors in tutorial script space shooter
Hi, working my way through the tutorial and I'm getting loads of errors from the tutorial script (I've tried copy pasting from the tutorial site and still getting the same errors) It was complaining of several missing semicolons which I have added in (I assume this was the correct thing to do and has made the errors go away) but these 2 errors persist: (7,12): BCE0043: unexpected token: float. and (7,18):BCE0044: expecting EOF, found 'xmin'
here is my code:
using; UnityEngine;
using; System.Collections;
[System.Serializable];
public class Boundary
{
public float xMin, xMax, zMin, zMax;
}
public class PlayerController : MonoBehaviour
{
public float speed;
public float tilt;
public Boundary boundary;
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement * speed;
rigidbody.position = new Vector3
(
Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax),
0.0f,
Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax)
);
rigidbody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.x * -tilt);
}
}
any help would be greatly appreciated.
for reference, the semi colons that I added were after both instances of the word "using" on lines 1 and 2 and after [System.Serializable] on line 4. I changed these due to the console error saying that there were missing semi colons at these references.
I remove the three ';' you inserted, and the file compiles without errors. I'm not sure what you are seeing. Any chance you put the script in a Javascript file ins$$anonymous$$d of a C# file?
Answer by Unholymess · Mar 05, 2014 at 01:24 AM
ohmyfreakinggod, I've just realised that it's a .js extension :/ I am officially an idiot! Thank you for suggesting that!! Can't believe that didn't occur to me :/ It seems to default as a .js in unity when i create a new script, how do I change that?
never$$anonymous$$d, just seen the option to change it. Thank you so much for pointing out where I'd gone wrong!!
Your answer
![](https://koobas.hobune.stream/wayback/20220613135404im_/https://answers.unity.com/themes/thub/images/avi.jpg)