I m getting error please solve my errors I m beginner in unity,Getting error of :

Hi,I m beginner and I write script but got 2 errors which are shown below
1- Assets/Scripts/NedmethodScript.cs(1,254): error CS1041: Identifier expected
2-Assets/Scripts/NedmethodScript.cs(1,254): error CS8025: Parsing error

Please resolve my issue.I m working on Roll a ball Project as learning so kindly help me as soon as possible

using UnityEngine;
 using System.Collections;
 
 public class CubeScript : MonoBehaviour {
     float MAX_SPEED = 1;
     Vector3 speed = Vector3.zero;
     public GameObject CameraGO;
     // Use this for initialization
     void Start () {
         CameraGO.transform.position = this.transform.position - 
             new Vector3 (0, -11, 0);
     }
     
     // Update is called once per frame
     void Update () {
 
 
 
         if (speed.x > 0.01f) {
             speed.x -= .01f;
                 }
 
         if (speed.z > 0.01f) {
             speed.z -= .01f;
         }
         this.transform.position += speed;
 
 
         if (Input.GetKey (KeyCode.UpArrow)) {
             speed = new Vector3(0,0,MAX_SPEED);
         }
 
         if(Input.GetKey(KeyCode.RightArrow))
             speed = new Vector3(MAX_SPEED,0,0);
 
         /*if(Input.GetKey(KeyCode.LeftArrow))
             this.transform.position += new Vector3 (-speed, 0, 0);
 
         if(Input.GetKey(KeyCode.DownArrow))
             this.transform.position += new Vector3 (0, 0, -speed);
 */
         float distance = Vector3.Distance (this.transform.position, CameraGO.transform.position);
         //if(Mathf.Abs(this.transform.position.z - CameraGO.transform.position.z) > 60)
         CameraGO.transform.position = this.transform.position - 
                         new Vector3 (0, -11, 30);
     }
 }

Please edit your question and add your code there instead of using screenshots. You can paste in your code and use the 101010 button to format it.

2 Answers

2

I think the error you are talking about is in the first line of your code, which doesn’t appear in your screenshots.
Your first two lines should look like this:

using UnityEngine;
using System.Collections;

Ok. Besides the class name issue, you missed a few “{” and “}”.

I’ve fixed it, including the commented out sections which also had parsing errors.

using UnityEngine;
using System.Collections;

public class NedmethodScript : MonoBehaviour {

	float MAX_SPEED = 1; 
	Vector3 speed = Vector3.zero; 
	public GameObject CameraGO;

	// Use this for initialization
	void Start () {
		CameraGO.transform.position = this.transform.position - new Vector3 (0, -11, 0);
	}
	
	// Update is called once per frame
	void Update () {
		if (speed.x > 0.01f) {
			speed.x -= .01f;
		}
		if (speed.z > 0.01f) {
			speed.z -= .01f;
		}

		this.transform.position += speed;

		if (Input.GetKey (KeyCode.UpArrow)) {
			speed = new Vector3 (0, 0, MAX_SPEED);
		}
		if (Input.GetKey (KeyCode.RightArrow)) {
			speed = new Vector3 (MAX_SPEED, 0, 0);
		}
		/*if (Input.GetKey (KeyCode.LeftArrow)) {
			this.transform.position += new Vector3 (-speed, 0, 0);
		}
		if (Input.GetKey (KeyCode.DownArrow)) {
			this.transform.position += new Vector3 (0, 0, -speed);
		}*/
		float distance = Vector3.Distance (this.transform.position, CameraGO.transform.position);
		/*if (Mathf.Abs (this.transform.position.z - CameraGO.transform.position.z) > 60) {
			//Do Stuff...
		}*/
		CameraGO.transform.position = this.transform.position - new Vector3 (0, -11, 30);
	}
}

By the way, as Dave Carlile suggested, it would be nice if you could edit your original post and add your code there, to make your thread easier to read.

Ok brother