Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void LoadChunks(Vector3 playerPos, float distToLoad, float distToUnload)
- {
- for (int x = 0; x < world.chunks.GetLength(0); x++)
- {
- for (int z = 0; z < world.chunks.GetLength(2); z++)
- {
- float dist = Vector2.Distance(new Vector2(x * world.chunkSize,
- z * world.chunkSize), new Vector2(playerPos.x, playerPos.z));
- if (dist < distToLoad)
- {
- if (world.chunks[x, 0, z] == null)
- {
- world.GenColumn(x, z);
- }
- }
- else if (dist > distToUnload)
- {
- if (world.chunks[x, 0, z] != null)
- {
- world.UnloadColumn(x, z);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement