void Start() { meshFilter = GetComponent <MeshFilter>(); meshCollider = GetComponent <MeshCollider>(); createMapFromScratch(); StartCoroutine(CreateVisualMesh()); // Reskin neighbor chunk meshes for boundary cases GameObject leftChunk = LandscapeManager.FindChunk(transform.position + new Vector3(-1, 0, 0)); if (leftChunk != null) { StartCoroutine(leftChunk.GetComponent <ChunkManager>().CreateVisualMesh()); } GameObject rightChunk = LandscapeManager.FindChunk(transform.position + new Vector3(ChunkWidth, 0, 0)); if (rightChunk != null) { StartCoroutine(rightChunk.GetComponent <ChunkManager>().CreateVisualMesh()); } GameObject frontChunk = LandscapeManager.FindChunk(transform.position + new Vector3(0, 0, -1)); if (frontChunk != null) { StartCoroutine(frontChunk.GetComponent <ChunkManager>().CreateVisualMesh()); } GameObject backChunk = LandscapeManager.FindChunk(transform.position + new Vector3(0, 0, ChunkWidth)); if (backChunk != null) { StartCoroutine(backChunk.GetComponent <ChunkManager>().CreateVisualMesh()); } }
public byte GetByte(int x, int y, int z) { if (y < 0) { return(0); } else if (y >= ChunkHeight) { return(2); } if ((x < 0) || (z < 0) || (x >= ChunkWidth) || (z >= ChunkWidth)) { Vector3 worldPos = new Vector3(x, y, z) + transform.position; GameObject chunk = LandscapeManager.FindChunk(worldPos); if (chunk == null) { return(1); } return(chunk.GetComponent <ChunkManager>().GetByte(worldPos)); } return(map[x, y, z]); }