- Home /
Is there a parsing error
I van t find it but it says it is on line 32 I think
using UnityEngine;
using System.Collections;
public class Playerstuff : MonoBehaviour {
private Transform gameObject;
public int playerSpeed = 20;
// Use this for initialization
void Start () {
gameObject = transform;
//spawn point stuff
gameObject.position = new Vector3(3,0,0);
}
// Update is called once per frame
void Update () {
//Player movement
gameObject.Translate(Vector3.right * Input.GetAxis ("Horizontal"));
//player "portal"
if (gameObject.position.x >=10) {
gameObject.position = new Vector3(-10, gameObject.position.y, gameObject.position.z);
}
}
Answer by jgodfrey · Jan 03, 2015 at 03:47 PM
If you use an editor with brace-matching ability, you'll see that you're (at least) missing the final closing brace for the class. Just add one more line with a closing brace --> "}".
Also, if you fix your code alignment, these issues are much easier to see.
And @X_rploader Boss sorry but nobody will vote up a question like this.
These kind of questions don't usually even get past moderation because the value of a question like this to other people is very low (it's basically a typo ins$$anonymous$$d of an actual program$$anonymous$$g problem of which the solution would be usable to others too).
As searching for "parsing error" on Unity Answers shows, this has been answered many many times on this forum (for example here - the answer applies to your problem also). You would've found help to your problem faster by searching than by asking a new question.
Answer by Graham-Dunnett · Jan 03, 2015 at 11:07 AM
Yes, there is a parsing error. You don't have a line 32, so the compiler has got confused. If you search for the error number on Google, you'll get loads of hits on this site which will help you out.
Answer by tanoshimi · Jan 03, 2015 at 11:23 AM
Actually, I don't see anything syntactically wrong with your code. If I had to guess, I'd say it was because you have tried to declare a variable called "gameObject", which is a keyword already declared by Unity (confusingly, you also declare that variable to be a Transform rather than a GameObject...?).
If you want to create your own variable, call it something else. If you want to use the GameObject to which this script is attached, use gameObject, but don't explicitly declare it.
thank you Graham you really helped me out and tanoshimi I will probably change it too. Can you guys vite up the question I wan to get some karma
I get the same error.
using UnityEngine;
using System.Collections;
public class Playerstuff : $$anonymous$$onoBehaviour {
private Transform gameObject;
public int playerSpeed = 20;
// Use this for initialization
void Start () {
gameObject = transform;
//spawn point stuff
gameObject.position = new Vector3(3,0,0);
}
// Update is called once per frame
void Update () {
//Player movement
gameObject.Translate(Vector3.right * Input.GetAxis ("Horizontal"));
//player "portal"
if (gameObject.position.x >=10) {
gameObject.position = new Vector3(-10, gameObject.position.y, gameObject.position.z);
}
}
Thanks guys u helped me out. And can you vote this question plz.
Have you actually changed anything? Also note @jgodfrey's spot below.
Your answer
Follow this Question
Related Questions
Error CS8025: Parsing error. HELP! 1 Answer
object rotating around parent 1 Answer
Pause With an exit button? 2 Answers
How do you code in unity 3.5 and what if any programs would you need 2 Answers
Buff System 1 Answer