I'm having trouble with errors.

Here is my code:

Here is the tutorial:

Here are my errors:

Assets/Scripts/ColliderExample.cs(17,33): error CS1525: Unexpected symbol (', expecting )‘, ,', ;’, [', or =’

Assets/Scripts/ColliderExample.cs(32,14): error CS0116: A namespace can only contain types and namespace declarations

Assets/Scripts/ColliderExample.cs(62,1): error CS8025: Parsing error

I managed to fix my code last night, but I’m really stuck on this one. I’ve been here for 3 hours trying to figure it out.

Yeah, there’s definitely some problems there. A few pieces of advice:

  • Don’t post images of your code - post the actual code using CODE tags
  • Line 15 defines a RemoveBlock method that takes no arguments, but then within that method ( at line 17 ) it attempts to redefine RemoveBlock with 2 float args. That’s a problem…
  • The tutorial you point to has a link to the completed code. Why not just use it? It doesn’t have the same issues as the above…

I’ve tried but it has errors too, a lot of issues.

Can anyone else help?

Apply the changes that jgodfrey proposed and then post the updated script here including the error messages.

Just for your information: It is not allowed to double post in this forum!

http://forum.unity3d.com/threads/223379-Coding-C-errors-HELP!!

Here are the errors:

Assets/Scripts/ColliderExample.cs(17,33): error CS1525: Unexpected symbol (', expecting )‘, ,', ;’, [', or =’

Assets/Scripts/ColliderExample.cs(34,19): error CS1519: Unexpected symbol `for’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(34,30): error CS1519: Unexpected symbol `<’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(34,35): error CS1519: Unexpected symbol `;’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(34,38): error CS1519: Unexpected symbol `++’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(35,38): error CS1519: Unexpected symbol `<’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(35,43): error CS1519: Unexpected symbol `;’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(35,46): error CS1519: Unexpected symbol `++’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(36,44): error CS1519: Unexpected symbol `)’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(38,60): error CS1519: Unexpected symbol `(’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(38,73): error CS1041: Identifier expected

Assets/Scripts/ColliderExample.cs(38,83): error CS1519: Unexpected symbol `,’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(38,85): error CS1519: Unexpected symbol `-’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(38,91): error CS1519: Unexpected symbol `/’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(38,108): error CS1519: Unexpected symbol `)’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(38,116): error CS1519: Unexpected symbol `/’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(40,64): error CS1041: Identifier expected

Assets/Scripts/ColliderExample.cs(40,74): error CS1519: Unexpected symbol `,’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(40,76): error CS1519: Unexpected symbol `-’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(40,82): error CS1519: Unexpected symbol `/’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(42,66): error CS1519: Unexpected symbol `=’ in class, struct, or interface member declaration

Assets/Scripts/ColliderExample.cs(45,41): error CS8025: Parsing error

That’s all of it. :slight_smile:

You have to use code tags, otherwise the formatting is horrible and there are no line numbers.

Edit: No one said that you need to move the Update () line somewhere else. Move it back. This will probably eliminate many errors.

using UnityEngine;
using System.Collections;

public class ColliderExample : MonoBehaviour {

	public GameObject terrain;
	private PolygonGenerator tScrips;
	public int size = 4;
	public bool circular = false;

	void Start () {
		tScript = terrain.GetComponent ("PolygonGenerator") as PolygonGenerator;
	}



		bool RemoveBlock(float offsetX, float offsetY){
			int x =Mathf.RoundToInt(transform.position.x+offsetX);
			int y=Mathf.RoundToInt(transform.position.y+1f+offsetY);

			if(x<tScript.blocks.GetLength(0)  y<tScript.blocks.GetLength(1)  x>=0  y>=0){

				if(tScript.blocks[x,y]!=0){
					tScript.blocks[x,y]=0;
					return true;
				}
			}
			return false;
		}
	
	void Update () {

	bool collision=false;
		for(int x=0;x<size;x++){
			for(int y=0;y<size;y++){
				if(circular){

					if(Vector2.Distance(new Vector2(x-(size/2),y-(size/2)),Vector2.zero)<=(size/3)){

						if(RemoveBlock(x-(size/2),y-(size/2))){

							collision=true;
						}

					}
				} else {


					if(RemoveBlock(x-(size/2),y-(size/2))){

						collision=true;
					}
				}
			}
		}
		if( collision){
			tScript.update=true;
		}
	}
}

Sorry I though I had put it in the Tags.

All of my errors are fixed now, thank you very much!! I’ll try to expand my knowledge of the Code/Errors/Forums. I’m new to all of the coding, and stuff.