You’re not likely to get much help unless you show the specific error you’re getting (cut and paste it). It should contain some detailed info that’ll help in resolving the problem.
As Ingot said, you have two opening brackets and only one closing bracket.
Also, regarding your PM, you can post in one of the links in my signature if you have any Cubiquity-specific questions. Obviously general scripting questions such as this one belong here.
Sorry, my mistake. The closing bracket was actually for the class (not the function) so you do need it. But your second opening bracket is pointing the wrong way as it should be a closing bracket for the function.
Basically, you’ll make your life easier if you use consistent indentation so you can see which brackets are paired up. The code below fixes your parse error, but it still doesn’t compile for me (e.g. render_distance is not defined). But you probably know how to fix this.
using UnityEngine;
using System.Collections;
public class Generator : MonoBehaviour
{
// Use this for initialization
void Start ()
{
GenerateChunks();
}
void GenerateChunks()
{
Vector3[] chunks = new Vector3[render_distance*render_distance];
bool[] chunksbool = new bool[render_distance*render_distance];
int i = 0;
for(int x=(render_distance/2)*-1;x<render_distance/2;x++)
{
for(int z=(render_distance/2)*-1;z<render_distance/2;z++)
{
int px = Mathf.RoundToInt(player.transform.position.x /16) * 16;
int pz = Mathf.RoundToInt(player.transform.position.z /16) * 16;
px = px+(x*16);
pz = pz+(z*16);
chunks[i] = new Vector3(px,0,pz);
chunksbool[i] = true;
i=i+1;
}
}
for(i=0;i<render_distance*render_distance;i++)
{
foreach (Transform child in transform)
{
if(child.transform.position == chunks[i])
{
chunksbool[i]=false;
}
}
}
for(i=0;i<render_distance*render_distance;i++)
{
if(chunksbool[i])
{
CreateChunk(chunks[i]);
}
}
}
void CreateChunk(Vector3 pos)
{
Transform chunk = Instantiate(Chunk,pos,Quaternion.identity) as Transform;
chunk.transform.parent = transform;
}
void DestroyChunks()
{
int px = Mathf.RoundToInt(player.position.x/16) * 16;
int pz = Mathf.RoundToInt(player.position.z/16) * 16;
int renderer = Mathf.RoundToInt(render_distance + (render_distance/2));
foreach (Transform child in transform)
{
Vector2 ch = new Vector2(child.transform.position.x,child.transform.position.z);
Vector2 pl = new Vector2(player.transform.position.x,player.transform.position.z);
float dist = Vector2.Distance(ch,pl);
if(dist>renderer*20)
{
Destroy(child.gameObject);
}
}
}
// Update is called once per frame
void Update ()
{
GenerateChunks();
DestroyChunks();
}
}