I got several Compiler errors (CS1519,CS1520, CS0178,CS8025)

Hi guys,

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Targetting : MonoBehaviour 
{

	public List <Transform> targets;
	public Transform SelectedTarget;
	private Transform myTransform;


	// Use this for initialization
	
	void Start () 
	{
		targets = new List <Transform> ();
		AddAllEnemies ();
		SelectedTarget = null;
		myTransform = transform;

	}

	public void AddAllEnemies()
	{
		GameObject[] go = GameObject.FindGameObjectsWithTag ("Enemy");

		foreach (GameObject enemy in go)
			AddTarget (enemy.transform);
		
	}

	public void AddTarget (Transform enemy)
	{
		targets.Add (enemy);

	}

	private void SortTargetsByDistance()
	{
		targets.Sort(delegate(Transform t1, Transform t2)
		             {
			return(Vector3.Distance(t1.position,myTransform.position).CompareTo(Vector3.Distance (t2.position, myTransform));
			       }); 
		             
			
	}
		private void TargetEnemy ();
	{
		if (SelectedTarget = null) 
			{
			SortTargetsByDistance();
			SelectedTarget = targets[0];
			}
		

		else
			{
				int index = Targetting.IndexOf(SelectedTargets);
				if(index < targets.Count - 1)
					{
					index ++
					}
				else
					{
					index = 0;
					}
				SelectedTarget = targets[index]; 
			}

	}

	// Update is called once per frame
	void Update () 
	{
	
		if (Input.GetKeyDown (KeyCode.Tab))
			{
			TargetEnemy();		
			}
	}
}

I got the mentioned errors several times:

CS8025(57,20) Parsing error

CS1519(53,52) Unexpected Symbol ‘;’ in class, stuct or interface member declaration

CS0178 Invalid rank specifier: expected ‘,’ or ]

CS1519 (53,40) Unexpected symbol ‘=’ in class, struct, or interface member declaration

CS1520(52,25) Class, struct or interface method must have a return type

CS1519 (50,36) Unexpected symbol ‘=’ in class, struct, or interface member declaration

CS1519 (49,9) Unexpected symbol ‘{’ in class, struct or interface member declaration

CS1026 (43,137) Unexpected symbol ‘;’ expecting ‘)’

I tried to figure out, why the CS1519 comes up repeteadly (well, I think missing or unexpected symbols should be easy to fix … but I was unable to do it for now …)
Every change I made did not alter anything with the Compiler errors
I also don’t get the CS8025 in line 57 (I guess I missed something)
The CS1026 seems weird to me too. I even changed the ‘;’ to a ‘)’ … no result …

Maybe Unity does not update the script I thought, so I restarted Unity with no result.
Now I’m definetly blown … I can’t figure out, how to make this work.

please dear fellows,
help me

thanks for every post

The first one, line 57, is just a basic programming error. I’d guess the rest are, as well. You’ll fix them a lot faster, and be taken a lot more seriously in later posts, if you get some basic debugging skills.

o Look at only the first error. The rest are often caused by the first, and go away when you fix that one.

o The exact number-type of an error, and the guess of what it is, aren’t very important. If the computer knew what it was, it wouldn’t be an error. The important thing is the line number. Most errors are caused by something either on the line, or before. Whenever you see “unexpected symbol” it means a previous line was messed up, and the line# it’s telling you is where it just gave up. In your code, look before line 57 to line 56. Then look at line 55.

o If you’re writing it yourself, type a little bit, then compile and check for errors. Then type more, test … . Try to write little parts that you can run and test. When you get an error, you only have to look at the few new things you added. Even the pros do it that way.

Hi,
I should have mentioned that I follow a tutorial (burgzergs rpg tutorial)

The first line 57 , I realized while reading your post, there s a semi-colon missing at the end of line 55.

whenever you see unexpected symbol…

I thought so too AND I read about it before posting. However I was let’s say unable to fix it … maybe I was only tired after long day at university, as mentioned before, line 55, missing semi-colon. In a good state of mind and after a night of sleep this would not have happened to me, I hope :smiley:

I really thank you for your answer,
I’ll look at the other issues probably not today… it’s another hard day at university and on the evening some private time,
I appreciate your answer very much, even if there are small hints of sarcasm (which is I think understandable :slight_smile: )